Skip to content

Commit

Permalink
Updates following sonar reports
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Sep 25, 2017
1 parent f86789c commit dcba658
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 18 deletions.
Expand Up @@ -522,7 +522,7 @@ public static <T> boolean equals(Set<T> left, Set<T> right) {
if (!found) return false;
rightItems.remove(foundItem);
}
return rightItems.size() == 0;
return rightItems.isEmpty();
}


Expand Down
Expand Up @@ -89,10 +89,7 @@ protected void harvestDescriptors(@Nonnull Class<?> instanceClass, @Nonnull Clas
PropertyDescriptor[] propertyDescriptors = GriffonClassUtils.getPropertyDescriptors(currentClass);
for (PropertyDescriptor pd : propertyDescriptors) {
Method writeMethod = pd.getWriteMethod();
if (null == writeMethod) { continue; }
if (isStatic(writeMethod.getModifiers())) {
continue;
}
if (null == writeMethod || isStatic(writeMethod.getModifiers())) { continue; }

Configured annotation = writeMethod.getAnnotation(Configured.class);
if (null == annotation) { continue; }
Expand Down Expand Up @@ -161,8 +158,8 @@ protected void doConfigurationInjection(@Nonnull Object instance, @Nonnull Map<S
}
}

@Nonnull
protected Object resolveConfiguration(@Nonnull String name, @Nonnull String key, @Nonnull String defaultValue) {
@Nullable
protected Object resolveConfiguration(@Nonnull String name, @Nonnull String key, @Nullable String defaultValue) {
Configuration configuration = getConfiguration();
if (!isBlank(name)) {
configuration = getConfiguration(name);
Expand Down
Expand Up @@ -16,7 +16,7 @@
package org.codehaus.griffon.runtime.core.configuration;

import javax.annotation.Nonnull;

import javax.annotation.Nullable;
import java.beans.PropertyEditor;

import static griffon.util.GriffonNameUtils.requireNonBlank;
Expand All @@ -32,7 +32,7 @@ public abstract class ConfigurationDescriptor {
private final String format;
private final Class<? extends PropertyEditor> editor;

public ConfigurationDescriptor(@Nonnull String configuration, @Nonnull String key, @Nonnull String defaultValue, @Nonnull String format, @Nonnull Class<? extends PropertyEditor> editor) {
public ConfigurationDescriptor(@Nonnull String configuration, @Nonnull String key, @Nullable String defaultValue, @Nonnull String format, @Nonnull Class<? extends PropertyEditor> editor) {
this.configuration = configuration;
this.key = requireNonBlank(key, "Argument 'key' must not be blank");
this.defaultValue = defaultValue;
Expand All @@ -50,7 +50,7 @@ public String getKey() {
return key;
}

@Nonnull
@Nullable
public String getDefaultValue() {
return defaultValue;
}
Expand Down
Expand Up @@ -16,6 +16,7 @@
package org.codehaus.griffon.runtime.core.configuration;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.beans.PropertyEditor;
import java.lang.reflect.Field;

Expand All @@ -28,7 +29,7 @@
public class FieldConfigurationDescriptor extends ConfigurationDescriptor {
private final Field field;

public FieldConfigurationDescriptor(@Nonnull Field field, @Nonnull String configuration, @Nonnull String key, @Nonnull String defaultValue, @Nonnull String format, @Nonnull Class<? extends PropertyEditor> editor) {
public FieldConfigurationDescriptor(@Nonnull Field field, @Nonnull String configuration, @Nonnull String key, @Nullable String defaultValue, @Nonnull String format, @Nonnull Class<? extends PropertyEditor> editor) {
super(configuration, key, defaultValue, format, editor);
this.field = requireNonNull(field, "Argument 'field' must not be null");
}
Expand Down
Expand Up @@ -16,6 +16,7 @@
package org.codehaus.griffon.runtime.core.configuration;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.beans.PropertyEditor;
import java.lang.reflect.Method;

Expand All @@ -28,7 +29,7 @@
public class MethodConfigurationDescriptor extends ConfigurationDescriptor {
private final Method writeMethod;

public MethodConfigurationDescriptor(@Nonnull Method writeMethod, @Nonnull String configuration, @Nonnull String key, @Nonnull String defaultValue, @Nonnull String format, @Nonnull Class<? extends PropertyEditor> editor) {
public MethodConfigurationDescriptor(@Nonnull Method writeMethod, @Nonnull String configuration, @Nonnull String key, @Nullable String defaultValue, @Nonnull String format, @Nonnull Class<? extends PropertyEditor> editor) {
super(configuration, key, defaultValue, format, editor);
this.writeMethod = requireNonNull(writeMethod, "Argument 'writeMethod' must not be null");
}
Expand Down
Expand Up @@ -497,7 +497,7 @@ protected boolean removeNestedListeners(@Nonnull Object owner) {
toRemove.add(listener);
}
}
removed = toRemove.size() > 0;
removed = !toRemove.isEmpty();
for (Object listener : toRemove) {
LOG.debug("Removing listener {} on {}", listener.getClass().getName(), capitalize(eventName));
listenerList.remove(listener);
Expand Down
Expand Up @@ -63,7 +63,7 @@ public ResourceBundle create(@Nonnull String basename, @Nonnull Locale locale) {
bundles.addAll(loadBundlesFor(basename + "_" + suffix));
}
bundles.addAll(loadBundlesFor(basename));
if (bundles.size() == 0) {
if (bundles.isEmpty()) {
throw new IllegalArgumentException("There are no ResourceBundle resources matching " + basename);
}

Expand Down
Expand Up @@ -142,7 +142,7 @@ public static Threading.Policy getThreadingPolicy(AnnotationNode annotation) {

public static Threading.Policy getThreadingPolicy(MethodNode method, Threading.Policy defaultPolicy) {
List<AnnotationNode> annotations = method.getAnnotations(THREADING_CNODE);
if (annotations.size() > 0) {
if (!annotations.isEmpty()) {
return getThreadingPolicy(annotations.get(0));
}
return defaultPolicy;
Expand Down
Expand Up @@ -303,7 +303,7 @@ protected ApplicationConfigurer getApplicationConfigurer() {
public void initialize() {
if (getPhase() == ApplicationPhase.INITIALIZE) {
Parameters parameters = getParameters();
if (parameters != null && parameters.getRaw().size() > 0) {
if (parameters != null && !parameters.getRaw().isEmpty()) {
int length = parameters.getRaw().size();
startupArgs = new String[length];
System.arraycopy(parameters.getRaw().toArray(), 0, startupArgs, 0, length);
Expand Down
Expand Up @@ -175,7 +175,7 @@ public void remove(@Nonnull Node node) {
}

public void first() {
if (nodes.size() > 0) {
if (!nodes.isEmpty()) {
show(0);
}
}
Expand Down
Expand Up @@ -86,7 +86,7 @@ protected Node loadFromFXML(@Nonnull String baseName) {

URL viewResource = getResourceAsURL(viewName);
if (viewResource == null) {
return null;
throw new IllegalStateException("resource " + viewName + " not found");
}

FXMLLoader fxmlLoader = createFxmlLoader(viewResource);
Expand Down

0 comments on commit dcba658

Please sign in to comment.