Skip to content

Commit eb89c94

Browse files
committed
chore: fix small linter complaints in AbstractEntity and ClasspathPropertiesVersionProvider
1 parent 210d6ac commit eb89c94

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/main/java/edu/kit/datamanager/ro_crate/entities/AbstractEntity.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,7 @@ private static boolean addProperty(ObjectNode whereToAdd, String key, JsonNode v
254254
public void addIdProperty(String name, String id) {
255255
if (id == null || id.isBlank()) { return; }
256256
mergeIdIntoValue(id, this.properties.get(name))
257-
.ifPresent(newValue -> {
258-
this.properties.set(name, newValue);
259-
});
257+
.ifPresent(newValue -> this.properties.set(name, newValue));
260258
this.linkedTo.add(id);
261259
this.notifyObservers();
262260
}
@@ -369,7 +367,7 @@ private static void checkFormatISO8601(String date) throws IllegalArgumentExcept
369367
/**
370368
* Adds a property with date time format. The property should match the ISO 8601
371369
* date format.
372-
*
370+
* <p>
373371
* Same as {@link #addProperty(String, String)} but with internal check.
374372
*
375373
* @param key key of the property (e.g. datePublished)
@@ -424,7 +422,7 @@ public T setId(String id) {
424422
if (IdentifierUtils.isValidUri(id)) {
425423
this.id = id;
426424
} else {
427-
this.id = IdentifierUtils.encode(id).get();
425+
this.id = IdentifierUtils.encode(id).orElse(this.id);
428426
}
429427
}
430428
return self();
@@ -461,7 +459,7 @@ public T addTypes(Collection<String> types) {
461459
/**
462460
* Adds a property with date time format. The property should match the ISO 8601
463461
* date format.
464-
*
462+
* <p>
465463
* Same as {@link #addProperty(String, String)} but with internal check.
466464
*
467465
* @param key key of the property (e.g. datePublished)
@@ -521,7 +519,7 @@ public T addProperty(String key, boolean value) {
521519
/**
522520
* ID properties are often used when referencing other entities within
523521
* the ROCrate. This method adds automatically such one.
524-
*
522+
* <p>
525523
* Instead of {@code "name": "id" }
526524
* this will add {@code "name" : {"@id": "id"} }
527525
*

src/main/java/edu/kit/datamanager/ro_crate/util/ClasspathPropertiesVersionProvider.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import java.util.Properties;
77

88
public class ClasspathPropertiesVersionProvider implements VersionProvider {
9-
private static final String PROPERTIES_FILE = "ro-crate-java.properties";
10-
private static final String VERSION_KEY = "version";
9+
public static final String VERSION_PROPERTIES = "version.properties";
1110

1211
/**
1312
* Cached version to avoid repeated file/resource reads.
@@ -27,14 +26,14 @@ public String getVersion() {
2726
return cachedVersion;
2827
}
2928

30-
URL resource = this.getClass().getResource("/version.properties");
31-
assert resource != null : "version.properties not found in classpath";
29+
URL resource = this.getClass().getResource("/" + VERSION_PROPERTIES);
30+
assert resource != null : VERSION_PROPERTIES + " not found in classpath";
3231

3332
try (InputStream input = resource.openStream()) {
3433
Properties properties = new Properties();
3534
properties.load(input);
3635
String version = properties.getProperty("version");
37-
assert version != null : "Version property not found in version.properties";
36+
assert version != null : "Version property not found in " + VERSION_PROPERTIES;
3837
return version.trim();
3938
} catch (IOException e) {
4039
throw new IllegalStateException("Failed to read version from properties file", e);

0 commit comments

Comments
 (0)