.setUuid(PROJECT_VIEW_1_UUID)
.setName(PROJECT_VIEW_1_NAME)
.setDescription("project view description is not persisted")
- .setProjectViewAttributes(new ProjectViewAttributes(project.uuid(), project.getKey(), analysisDate, null));
+ .setProjectViewAttributes(new ProjectViewAttributes(project.uuid(), project.getKey(), analysisDate, true, null));
}
private void persistComponents(ComponentDto... componentDtos) {
private final String originalKey;
@CheckForNull
private final Long analysisDate;
+ private final boolean hasNewCodePeriod;
private final String branchName;
- public ProjectViewAttributes(String uuid, String originalKey, @Nullable Long analysisDate, @Nullable String branchName) {
+ public ProjectViewAttributes(String uuid, String originalKey, @Nullable Long analysisDate, boolean hasNewCodePeriod, @Nullable String branchName) {
this.uuid = requireNonNull(uuid, "uuid can't be null");
this.originalKey = requireNonNull(originalKey, "originalKey can't be null");
this.analysisDate = analysisDate;
+ this.hasNewCodePeriod = hasNewCodePeriod;
this.branchName = branchName;
}
return originalKey;
}
+ public boolean hasNewCodePeriod() {
+ return hasNewCodePeriod;
+ }
+
@Override
public String toString() {
return "ProjectViewAttributes{" +
- ", uuid='" + uuid + '\'' +
- ", branchName='" + branchName + '\'' +
- ", analysisDate=" + analysisDate +
- '}';
+ ", uuid='" + uuid + '\'' +
+ ", branchName='" + branchName + '\'' +
+ ", hasNewCodePeriod=" + branchName +
+ ", analysisDate=" + analysisDate +
+ '}';
}
}
@Override
public Optional<Measure> createMeasure(IntSumCounter counter, CreateMeasureContext context) {
Optional<Integer> valueOptional = counter.getValue();
- if (shouldCreateMeasure(context, valueOptional)) {
- return Optional.of(Measure.newMeasureBuilder().create(valueOptional.get()));
+ Integer value = valueOptional.orElse(null);
+ if (shouldCreateMeasure(context, value)) {
+ return Optional.of(Measure.newMeasureBuilder().create(value));
}
return Optional.empty();
}
@Override
public Optional<Measure> createMeasure(LongSumCounter counter, CreateMeasureContext context) {
Optional<Long> valueOptional = counter.getValue();
- if (shouldCreateMeasure(context, valueOptional)) {
- return Optional.of(Measure.newMeasureBuilder().create(valueOptional.get()));
+ Long value = valueOptional.orElse(null);
+ if (shouldCreateMeasure(context, value)) {
+
+ return Optional.of(Measure.newMeasureBuilder().create(value));
}
return Optional.empty();
}
}
- private static <T extends Number> boolean shouldCreateMeasure(CreateMeasureContext context, Optional<T> value) {
- return value.isPresent() && CrawlerDepthLimit.LEAVES.isDeeperThan(context.getComponent().getType());
+ protected static <T extends Number> boolean shouldCreateMeasure(CreateMeasureContext context, @Nullable T value) {
+ return value != null && CrawlerDepthLimit.LEAVES.isDeeperThan(context.getComponent().getType());
}
@Override