Commit 39638392 authored by Mathijs den Burger's avatar Mathijs den Burger

HSTCONFIGEDIT-174: replace size() with isEmpty() where possible

parent 33e86af2
......@@ -128,7 +128,7 @@ public class ContainerItemComponentEditorPlugin extends BasicEditorPlugin<Contai
final DropDownChoice<Parameter> ddo = new DropDownChoice<Parameter>("parameterOverrides", overrides) {
@Override
public boolean isVisible() {
return overrides.size() > 0;
return !overrides.isEmpty();
}
};
ddo.setNullValid(false);
......
......@@ -106,7 +106,7 @@ public class ParametersWidget extends Panel {
@Override
public boolean isVisible() {
return model.getObject().getParameters().size() > 0;
return !model.getObject().getParameters().isEmpty();
}
};
containers.setOutputMarkupId(true);
......
......@@ -32,7 +32,7 @@ public class AddRestrictedComponentDialog extends AddNodeDialog<Component> {
public AddRestrictedComponentDialog(ComponentDAO dao, RenderPlugin plugin, JcrNodeModel parent, List<String> choices) {
super(dao, plugin, parent);
if (choices == null || choices.size() == 0) {
if (choices == null || choices.isEmpty()) {
throw new IllegalArgumentException("List of choices cannot be null or empty");
}
getBean().setName(choices.get(0));
......
......@@ -32,7 +32,7 @@ public class AddRestrictedContainerComponentDialog extends AddNodeDialog<Contain
public AddRestrictedContainerComponentDialog(ContainerComponentDAO dao, RenderPlugin plugin, JcrNodeModel parent, List<String> choices) {
super(dao, plugin, parent);
if (choices == null || choices.size() == 0) {
if (choices == null || choices.isEmpty()) {
throw new IllegalArgumentException("List of choices cannot be null or empty");
}
getBean().setName(choices.get(0));
......
......@@ -122,7 +122,7 @@ public class ComponentEditorPlugin extends BasicEditorPlugin<Component> {
@Override
public boolean isVisible() {
return overrides.size() > 0;
return !overrides.isEmpty();
}
@Override
......@@ -149,7 +149,7 @@ public class ComponentEditorPlugin extends BasicEditorPlugin<Component> {
private void checkState() {
choices = getChoices();
boolean set = choices != null && choices.size() > 0;
boolean set = choices != null && !choices.isEmpty();
if (addLink.isVisible() != set) {
addLink.setVisible(set);
}
......@@ -187,7 +187,7 @@ public class ComponentEditorPlugin extends BasicEditorPlugin<Component> {
} catch (RepositoryException e) {
log.error("An error occurred during filtering of existing child nodes", e);
}
if (choices.size() == 0) {
if (choices.isEmpty()) {
addLink.setVisible(false);
}
}
......@@ -235,7 +235,7 @@ public class ComponentEditorPlugin extends BasicEditorPlugin<Component> {
}) {
@Override
public boolean isVisible() {
return availableComponents.size() > 0;
return !availableComponents.isEmpty();
}
};
ddo.setNullValid(false);
......
......@@ -97,7 +97,7 @@ public class ComponentDAO extends EditorDAO<Component> {
if (JcrUtilities.hasProperty(model, HST_PARAMETERNAMES)) {
List<String> names = JcrUtilities.getMultiValueProperty(model, HST_PARAMETERNAMES);
if (names != null && names.size() > 0) {
if (names != null && !names.isEmpty()) {
String[] values = new String[names.size()];
if (JcrUtilities.hasProperty(model, HST_PARAMETERVALUES)) {
values = JcrUtilities.getMultiValueProperty(model, HST_PARAMETERVALUES).toArray(values);
......@@ -156,7 +156,7 @@ public class ComponentDAO extends EditorDAO<Component> {
*/
private void updateTemplate(Component currentComponent, Component previousComponent) {
List<String> previousContainers = getContainers(previousComponent);
if (previousContainers == null || previousContainers.size() == 0) {
if (previousContainers == null || previousContainers.isEmpty()) {
return;
}
......
......@@ -104,7 +104,7 @@ public class ContainerItemComponentDAO extends EditorDAO<ContainerItemComponent>
if (JcrUtilities.hasProperty(model, HST_PARAMETERNAMES)) {
List<String> names = JcrUtilities.getMultiValueProperty(model, HST_PARAMETERNAMES);
if (names != null && names.size() > 0) {
if (names != null && !names.isEmpty()) {
String[] values = new String[names.size()];
if (JcrUtilities.hasProperty(model, HST_PARAMETERVALUES)) {
values = JcrUtilities.getMultiValueProperty(model, HST_PARAMETERVALUES).toArray(values);
......@@ -157,7 +157,7 @@ public class ContainerItemComponentDAO extends EditorDAO<ContainerItemComponent>
*/
private void updateTemplate(ContainerItemComponent currentComponent, ContainerItemComponent previousComponent) {
List<String> previousContainers = getContainers(previousComponent);
if (previousContainers == null || previousContainers.size() == 0) {
if (previousContainers == null || previousContainers.isEmpty()) {
return;
}
......
......@@ -71,7 +71,7 @@ public class SitemapItemDAO extends EditorDAO<SitemapItem> {
if (JcrUtilities.hasProperty(model, HST_PARAMETERNAMES)) {
List<String> names = JcrUtilities.getMultiValueProperty(model, HST_PARAMETERNAMES);
if (names != null && names.size() > 0) {
if (names != null && !names.isEmpty()) {
String[] values = new String[names.size()];
if (JcrUtilities.hasProperty(model, HST_PARAMETERVALUES)) {
values = JcrUtilities.getMultiValueProperty(model, HST_PARAMETERVALUES).toArray(values);
......
......@@ -104,7 +104,7 @@ public class SitemenuItemDAO extends EditorDAO<SitemenuItem> {
if (JcrUtilities.hasProperty(model, HST_PARAMETERNAMES)) {
List<String> names = JcrUtilities.getMultiValueProperty(model, HST_PARAMETERNAMES);
if (names != null && names.size() > 0) {
if (names != null && !names.isEmpty()) {
String[] values = new String[names.size()];
if (JcrUtilities.hasProperty(model, HST_PARAMETERVALUES)) {
values = JcrUtilities.getMultiValueProperty(model, HST_PARAMETERVALUES).toArray(values);
......
......@@ -111,7 +111,7 @@ public abstract class NewPageWizard extends AjaxWizard {
public IDynamicWizardStep next() {
JcrNodeModel template = new JcrNodeModel(hstContext.template.absolutePath(newPage.getTemplate()));
List<String> containers = JcrUtilities.getMultiValueProperty(template, TemplateDAO.HST_CONTAINERS);
if (containers != null && containers.size() > 0) {
if (containers != null && !containers.isEmpty()) {
containersModel = new Containers(containers);
return new ComponentDescriptionStep(this);
}
......
......@@ -91,7 +91,7 @@ public class TemplateEditorPlugin extends BasicEditorPlugin<Template> {
@Override
public boolean isVisible() {
return getBean().getContainers().size() > 0;
return !getBean().getContainers().isEmpty();
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment