diff --git a/pom.xml b/pom.xml
index bc3e8b5..a1a13c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
edu.kit.kastel.sdq
artemis4j
- 7.4.2-SNAPSHOT
+ 7.5.0-SNAPSHOT
Artemis4J
Artemis4J is a Java library for interacting with the Artemis teaching system.
diff --git a/src/main/java/edu/kit/kastel/sdq/artemis4j/LazyNetworkValue.java b/src/main/java/edu/kit/kastel/sdq/artemis4j/LazyNetworkValue.java
index 674d81f..b214bee 100644
--- a/src/main/java/edu/kit/kastel/sdq/artemis4j/LazyNetworkValue.java
+++ b/src/main/java/edu/kit/kastel/sdq/artemis4j/LazyNetworkValue.java
@@ -20,8 +20,8 @@ public T get() throws ArtemisNetworkException {
// Second synchronized check to avoid double initialization
if (this.value == null) {
this.value = this.supplier.get();
- localValue = this.value;
}
+ localValue = this.value;
}
}
diff --git a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/Annotation.java b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/Annotation.java
index 6f2cc32..d9bb78d 100644
--- a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/Annotation.java
+++ b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/Annotation.java
@@ -21,9 +21,9 @@ public final class Annotation {
private final String filePath;
private final int startLine;
private final int endLine;
- private final String customMessage;
- private final Double customScore;
private final AnnotationSource source;
+ private String customMessage;
+ private Double customScore;
/**
* Deserializes an annotation from its metajson format
@@ -34,9 +34,9 @@ public Annotation(AnnotationDTO dto, MistakeType mistakeType) {
this.filePath = dto.classFilePath();
this.startLine = dto.startLine();
this.endLine = dto.endLine();
+ this.source = dto.source() != null ? dto.source() : AnnotationSource.UNKNOWN;
this.customMessage = dto.customMessageForJSON();
this.customScore = dto.customPenaltyForJSON();
- this.source = dto.source() != null ? dto.source() : AnnotationSource.UNKNOWN;
}
Annotation(
@@ -126,6 +126,14 @@ public Optional getCustomMessage() {
return Optional.ofNullable(customMessage);
}
+ public void setCustomMessage(String message) {
+ if (this.type.isCustomAnnotation() && message == null) {
+ throw new IllegalArgumentException("A custom message is required for custom annotation types.");
+ }
+
+ this.customMessage = message;
+ }
+
/**
* The custom score associated with this message, if any. Is always empty for
* predefined annotations, and never empty for custom annotations.
@@ -134,6 +142,17 @@ public Optional getCustomScore() {
return Optional.ofNullable(customScore);
}
+ public void setCustomScore(Double score) {
+ if (!this.type.isCustomAnnotation() && score != null) {
+ throw new IllegalArgumentException("A custom score is not allowed for non-custom annotation types.");
+ }
+ if (this.type.isCustomAnnotation() && score == null) {
+ throw new IllegalArgumentException("A custom score is required for custom annotation types.");
+ }
+
+ this.customScore = score;
+ }
+
public AnnotationSource getSource() {
return source;
}
diff --git a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/penalty/ThresholdPenaltyRule.java b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/penalty/ThresholdPenaltyRule.java
index df84625..88481b1 100644
--- a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/penalty/ThresholdPenaltyRule.java
+++ b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/penalty/ThresholdPenaltyRule.java
@@ -26,4 +26,8 @@ public Points calculatePoints(List annotations) {
}
return new Points(0.0, false);
}
+
+ public int getThreshold() {
+ return threshold;
+ }
}