@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
public final class DefaultResourceTypes extends ExtensionProvider implements BatchExtension, ServerExtension {
+
+ private static final String SUPPORTS_MEASURE_FILTERS = "supportsMeasureFilters";
+
@Override
public ResourceTypeTree provide() {
return ResourceTypeTree.builder()
.setProperty("modifiable_history", true)
.setProperty("hasRolePolicy", true)
.setProperty("updatable_key", true)
- .setProperty("supportsMeasureFilters", true)
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
.setProperty("comparable", true)
.setProperty("configurable", true)
.build())
.addType(ResourceType.builder(Qualifiers.MODULE)
.setProperty("updatable_key", true)
- .setProperty("supportsMeasureFilters", true)
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
.setProperty("configurable", true)
.build())
.addType(ResourceType.builder(Qualifiers.DIRECTORY)
- .setProperty("supportsMeasureFilters", true)
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
.build())
.addType(ResourceType.builder(Qualifiers.PACKAGE)
.build())
.addType(ResourceType.builder(Qualifiers.FILE)
.hasSourceCode()
- .setProperty("supportsMeasureFilters", true)
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
.build())
.addType(ResourceType.builder(Qualifiers.CLASS)
.hasSourceCode()
.build())
.addType(ResourceType.builder(Qualifiers.UNIT_TEST_FILE)
.hasSourceCode()
- .setProperty("supportsMeasureFilters", true)
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
.build())
.addRelations(Qualifiers.PROJECT, Qualifiers.MODULE)
public void decorate(Resource resource, DecoratorContext context) {
if (shouldDecorate(resource)) {
- int maxPeriods = (Qualifiers.isView(resource, true) ? 3 : 5);
+ int maxPeriods = Qualifiers.isView(resource, true) ? 3 : 5;
aggregate(context, CoreMetrics.NEW_LINES_TO_COVER, maxPeriods);
aggregate(context, CoreMetrics.NEW_UNCOVERED_LINES, maxPeriods);
aggregate(context, CoreMetrics.NEW_CONDITIONS_TO_COVER, maxPeriods);
}
if (hasLcom4 && totalFiles > 0) {
- context.saveMeasure(CoreMetrics.SUSPECT_LCOM4_DENSITY, (total / totalFiles));
+ context.saveMeasure(CoreMetrics.SUSPECT_LCOM4_DENSITY, total / totalFiles);
}
}
private Label createNonDiagonalCell(final int row, final int col, int weight) {
Label cell;
- cell = buildCell(row, col, weight, (col > row ? GRID_CELL_TOP_RIGHT : GRID_CELL_BOTTOM_LEFT));
+ cell = buildCell(row, col, weight, col > row ? GRID_CELL_TOP_RIGHT : GRID_CELL_BOTTOM_LEFT);
if (weight > 0) {
String tooltip = data.get(col).getName() + " -> " + data.get(row).getName() + " (" + weight + "). " + Dictionary.getDictionary("l10n").get("design.cellTooltip");
MavenPlugin plugin = MavenPlugin.getPlugin(project.getPom(), handler.getGroupId(), handler.getArtifactId());
execute(project,
fs,
- getGoal(handler.getGroupId(), handler.getArtifactId(), (plugin != null && plugin.getPlugin() != null ? plugin.getPlugin().getVersion() : null), goal));
+ getGoal(handler.getGroupId(), handler.getArtifactId(), plugin != null && plugin.getPlugin() != null ? plugin.getPlugin().getVersion() : null, goal));
}
return handler;
}
}
static String getGoal(String groupId, String artifactId, @Nullable String version, String goal) {
- String defaultVersion = (version == null ? "" : version);
+ String defaultVersion = version == null ? "" : version;
return new StringBuilder()
.append(groupId).append(":")
.append(artifactId).append(":")
Preconditions.checkArgument(!Strings.isNullOrEmpty(key), "Key must be set");
fixType(key, type);
Preconditions.checkArgument(onQualifiers.isEmpty() || onlyOnQualifiers.isEmpty(), "Cannot define both onQualifiers and onlyOnQualifiers");
- Preconditions.checkArgument((!hidden || (onQualifiers.isEmpty()) && onlyOnQualifiers.isEmpty()), "Cannot be hidden and defining qualifiers on which to display");
+ Preconditions.checkArgument(!hidden || (onQualifiers.isEmpty() && onlyOnQualifiers.isEmpty()), "Cannot be hidden and defining qualifiers on which to display");
if (hidden) {
global = false;
}
@CheckForNull
public Date createdAfter() {
- return (createdAfter == null ? null : new Date(createdAfter.getTime()));
+ return createdAfter == null ? null : new Date(createdAfter.getTime());
}
@CheckForNull
public Date createdAt() {
- return (createdAt == null ? null : new Date(createdAt.getTime()));
+ return createdAt == null ? null : new Date(createdAt.getTime());
}
@CheckForNull
public Date createdBefore() {
- return (createdBefore == null ? null : new Date(createdBefore.getTime()));
+ return createdBefore == null ? null : new Date(createdBefore.getTime());
}
@CheckForNull
}
public Builder createdAt(@Nullable Date d) {
- this.createdAt = (d == null ? null : new Date(d.getTime()));
+ this.createdAt = d == null ? null : new Date(d.getTime());
return this;
}
public Builder createdAfter(@Nullable Date d) {
- this.createdAfter = (d == null ? null : new Date(d.getTime()));
+ this.createdAfter = d == null ? null : new Date(d.getTime());
return this;
}
public Builder createdBefore(@Nullable Date d) {
- this.createdBefore = (d == null ? null : new Date(d.getTime()));
+ this.createdBefore = d == null ? null : new Date(d.getTime());
return this;
}
@Override
String format(Integer s) {
- return (s == null ? "" : String.valueOf(s));
+ return s == null ? "" : String.valueOf(s);
}
@Override
@Override
String format(RulePriority s) {
- return (s == null ? "" : s.toString());
+ return s == null ? "" : s.toString();
}
@Override
@Override
String format(Double d) {
- return (d == null ? "" : String.valueOf(d));
+ return d == null ? "" : String.valueOf(d);
}
@Override
@Override
String format(Date d) {
- return (d == null ? "" : dateFormat.format(d));
+ return d == null ? "" : dateFormat.format(d);
}
@Override
for (String pair : pairs) {
String[] keyValue = StringUtils.split(pair, FIELD_SEPARATOR);
String key = keyValue[0];
- String value = (keyValue.length == 2 ? keyValue[1] : "");
+ String value = keyValue.length == 2 ? keyValue[1] : "";
map.put(keyConverter.parse(key), valueConverter.parse(value));
}
}
for (String pair : pairs) {
String[] keyValue = StringUtils.split(pair, FIELD_SEPARATOR);
String key = keyValue[0];
- String value = (keyValue.length == 2 ? keyValue[1] : "0");
+ String value = keyValue.length == 2 ? keyValue[1] : "0";
multiset.add(keyConverter.parse(key), new IntegerConverter().parse(value));
}
}
return ((Integer)o).longValue();
}
if (o instanceof Long) {
- return ((Long) o);
+ return (Long) o;
}
if (o instanceof String) {
if (StringUtils.isBlank((String)o)) {
}
public boolean hasChildren() {
- return children != null && children.size() != 0;
+ return children != null && !children.isEmpty();
}
public boolean hasAmongParents(SourceCode expectedParent) {
* @since 2.10
*/
public final AbstractQuery<M> setTimeoutMilliseconds(int i) {
- this.timeoutMilliseconds = (i < 0 ? 0 : i);
+ this.timeoutMilliseconds = i<0 ? 0 : i;
return this;
}
protected static void appendUrlParameter(StringBuilder url, String paramKey, @Nullable Date paramValue, boolean includeTime) {
if (paramValue != null) {
- String format = (includeTime ? "yyyy-MM-dd'T'HH:mm:ssZ" : "yyyy-MM-dd");
+ String format = includeTime ? "yyyy-MM-dd'T'HH:mm:ssZ" : "yyyy-MM-dd";
url.append(paramKey)
.append('=')
.append(encode(WSUtils.getINSTANCE().format(paramValue, format)))
return dateFormat.parse(value);
} catch (ParseException e) {
- throw new RuntimeException(e);
+ throw new IllegalArgumentException("Fail to parse date property '" + field + "': " + format, e);
}
}
return null;