return componentQualifiers;
}
- public Collection<ComponentDto> getByUuids(DbSession session, Collection<String> componentUuids) {
+ public Collection<ComponentDto> getByUuids(DbSession session, @Nullable Collection<String> componentUuids) {
Set<ComponentDto> directoryPaths = Sets.newHashSet();
if (componentUuids != null && !componentUuids.isEmpty()) {
List<ComponentDto> components = dbClient.componentDao().selectByUuids(session, componentUuids);
builder.projectUuids(projectUuids);
}
- private Collection<String> authorsFromParamsOrFromDeveloper(DbSession session, Collection<String> componentUuids, Collection<String> authors) {
+ private Collection<String> authorsFromParamsOrFromDeveloper(DbSession session, Collection<String> componentUuids,
+ @Nullable Collection<String> authors) {
return authors == null ? dbClient.authorDao().selectScmAccountsByDeveloperUuids(session, componentUuids) : authors;
}
}
public Object getCoreComponentByClassname(String className) {
- if (className == null) {
- return null;
- }
-
try {
return get(Class.forName(className));
} catch (ClassNotFoundException e) {
private final Map<String, String> deprecatedKeys = new HashMap<>();
public PropertyDefinitions(Object... components) {
- if (components != null) {
- addComponents(Arrays.asList(components));
- }
+ addComponents(Arrays.asList(components));
}
public PropertyDefinitions(Collection<PropertyDefinition> components) {
* @param metric the metric
* @param level the alert level
*/
- public Measure(Metric metric, Metric.Level level) {
+ public Measure(Metric metric, @Nullable Metric.Level level) {
this.metric = metric;
this.metricKey = metric.getKey();
if (level != null) {
* @param i the value
* @return the measure object instance
*/
- public Measure<G> setIntValue(Integer i) {
+ public Measure<G> setIntValue(@Nullable Integer i) {
if (i == null) {
this.value = null;
} else {
* @param level the alert level
* @return the measure object instance
*/
- public Measure<G> setData(Metric.Level level) {
+ public Measure<G> setData(@Nullable Metric.Level level) {
if (level == null) {
this.data = null;
} else {
* @return true if all measures numeric values
*/
public static boolean haveValues(Measure... measures) {
- if (measures == null || measures.length == 0) {
+ if (measures.length == 0) {
return false;
}
for (Measure measure : measures) {
return defaultValue;
}
- public static Double getVariation(Measure measure, int periodIndex) {
+ public static Double getVariation(@Nullable Measure measure, int periodIndex) {
return getVariation(measure, periodIndex, null);
}
- public static Double getVariation(Measure measure, int periodIndex, @Nullable Double defaultValue) {
+ public static Double getVariation(@Nullable Measure measure, int periodIndex, @Nullable Double defaultValue) {
Double result = null;
if (measure != null) {
result = measure.getVariation(periodIndex);
return result != null ? result : defaultValue;
}
- public static Long getVariationAsLong(Measure measure, int periodIndex) {
+ public static Long getVariationAsLong(@Nullable Measure measure, int periodIndex) {
return getVariationAsLong(measure, periodIndex, null);
}
- public static Long getVariationAsLong(Measure measure, int periodIndex, @Nullable Long defaultValue) {
+ public static Long getVariationAsLong(@Nullable Measure measure, int periodIndex, @Nullable Long defaultValue) {
Double result = null;
if (measure != null) {
result = measure.getVariation(periodIndex);
* @param measure the measure
* @return whether the measure has a value
*/
- public static boolean hasValue(Measure measure) {
+ public static boolean hasValue(@Nullable Measure measure) {
return measure != null && measure.getValue() != null;
}
* @param measure the measure
* @return whether the measure has a data field
*/
- public static boolean hasData(Measure measure) {
+ public static boolean hasData(@Nullable Measure measure) {
return measure != null && StringUtils.isNotBlank(measure.getData());
}
* @param measures the series of measures
* @return the sum of the measure series
*/
- public static Double sum(boolean zeroIfNone, Collection<Measure> measures) {
+ public static Double sum(boolean zeroIfNone, @Nullable Collection<Measure> measures) {
if (measures != null) {
return sum(zeroIfNone, measures.toArray(new Measure[measures.size()]));
}
* @return the sum of the measure series
*/
public static Double sum(boolean zeroIfNone, Measure... measures) {
- if (measures == null) {
- return zeroIfNone(zeroIfNone);
- }
Double sum = 0d;
boolean hasValue = false;
for (Measure measure : measures) {
* @param measures the series of measures
* @return the sum of the variations for the measure series
*/
- public static Double sumOnVariation(boolean zeroIfNone, int variationIndex, Collection<Measure> measures) {
+ public static Double sumOnVariation(boolean zeroIfNone, int variationIndex, @Nullable Collection<Measure> measures) {
if (measures == null) {
return zeroIfNone(zeroIfNone);
}
package org.sonar.api.measures;
import java.util.Collection;
+import javax.annotation.Nullable;
/**
* @since 1.10
@Deprecated
public interface MeasuresFilter<M> {
- M filter(Collection<Measure> measures);
+ M filter(@Nullable Collection<Measure> measures);
}
}
public abstract static class Converter<T> {
- abstract String format(T type);
+ abstract String format(@Nullable T type);
@CheckForNull
abstract T parse(String s);
+
String escape(String s) {
if (s.contains(FIELD_SEPARATOR) || s.contains(PAIR_SEPARATOR)) {
return new StringBuilder()
}
@Override
- String format(String s) {
- return escape(s);
+ String format(@Nullable String s) {
+ return s == null ? "" : escape(s);
}
@Override
}
@Override
- String format(Object o) {
- return escape(o.toString());
+ String format(@Nullable Object o) {
+ return o == null ? "" : escape(o.toString());
}
@Override
}
@Override
- String format(Integer s) {
+ String format(@Nullable Integer s) {
return s == null ? "" : String.valueOf(s);
}
}
@Override
- String format(RulePriority s) {
+ String format(@Nullable RulePriority s) {
return s == null ? "" : s.toString();
}
}
@Override
- String format(Double d) {
+ String format(@Nullable Double d) {
return d == null ? "" : String.valueOf(d);
}
}
@Override
- String format(Date d) {
+ String format(@Nullable Date d) {
return d == null ? "" : dateFormat.format(d);
}
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
+import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
/**
*
* @see #create(String, String)
*/
- public static WildcardPattern[] create(String[] patterns) {
+ public static WildcardPattern[] create(@Nullable String[] patterns) {
if (patterns == null) {
return new WildcardPattern[0];
}
private Map<Object, Node> registeredObjects = new HashMap<>();
private List<Node> nodes = new ArrayList<>();
- public DirectAcyclicGraph(final Object... objects) {
- if (objects != null) {
- for (Object object : objects) {
- add(object);
- }
+ public DirectAcyclicGraph(Object... objects) {
+ for (Object object : objects) {
+ add(object);
}
}
- public Node add(final Object object, final Object... dependencies) {
+ public Node add(Object object, Object... dependencies) {
Node node = registeredObjects.get(object);
if (node == null) {
node = new Node(object);
registeredObjects.put(object, node);
}
- if (dependencies != null) {
- for (Object dependency : dependencies) {
- Node depNode = add(dependency);
- node.addDependency(depNode);
- }
+ for (Object dependency : dependencies) {
+ Node depNode = add(dependency);
+ node.addDependency(depNode);
}
return node;
}