Skip to content

Commit 6a940e8

Browse files
committed
refactor: rename metadata context accessors to use "read" prefix to indicate (documented) immutability
1 parent 1786cdb commit 6a940e8

6 files changed

Lines changed: 26 additions & 26 deletions

File tree

src/main/java/edu/kit/datamanager/ro_crate/Crate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ public interface Crate {
5757
* @param key the key to be searched
5858
* @return the value of the key, null if not found
5959
*/
60-
String getMetadataContextValueOf(String key);
60+
String readMetadataContextValueOf(String key);
6161

6262
/**
6363
* Get an immutable collection of the keys in the metadata context.
6464
* @return the keys in the metadata context
6565
*/
66-
Set<String> getMetadataContextKeys();
66+
Set<String> readMetadataContextKeys();
6767

6868
/**
6969
* Get an immutable map of the context.
7070
* @return an immutable map containing the context key-value pairs
7171
*/
72-
Map<String, String> getMetadataContextPairs();
72+
Map<String, String> readMetadataContextPairs();
7373

7474
RootDataEntity getRootDataEntity();
7575

src/main/java/edu/kit/datamanager/ro_crate/RoCrate.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ public void setMetadataContext(CrateMetadataContext metadataContext) {
6262
this.metadataContext = metadataContext;
6363
}
6464

65-
public String getMetadataContextValueOf(String key) {
66-
return this.metadataContext.getValueOf(key);
65+
public String readMetadataContextValueOf(String key) {
66+
return this.metadataContext.readValueOf(key);
6767
}
6868

6969
@Override
70-
public Set<String> getMetadataContextKeys() {
71-
return this.metadataContext.getImmutableKeys();
70+
public Set<String> readMetadataContextKeys() {
71+
return this.metadataContext.readKeys();
7272
}
7373

7474
@Override
75-
public Map<String, String> getMetadataContextPairs() {
76-
return this.metadataContext.getImmutablePairs();
75+
public Map<String, String> readMetadataContextPairs() {
76+
return this.metadataContext.readPairs();
7777
}
7878

7979
public ContextualEntity getJsonDescriptor() {

src/main/java/edu/kit/datamanager/ro_crate/context/CrateMetadataContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ public interface CrateMetadataContext {
3030
* @param key the key to be searched
3131
* @return the value of the key, null if not found
3232
*/
33-
String getValueOf(String key);
33+
String readValueOf(String key);
3434

3535
/**
3636
* Get an immutable collection of the keys in the metadata context.
3737
* @return the keys in the metadata context
3838
*/
39-
Set<String> getImmutableKeys();
39+
Set<String> readKeys();
4040

4141
/**
4242
* Get an immutable map of the context.
4343
* @return an immutable map containing the context key-value pairs
4444
*/
45-
Map<String, String> getImmutablePairs();
45+
Map<String, String> readPairs();
4646

4747
void deleteValuePairFromContext(String key);
4848

src/main/java/edu/kit/datamanager/ro_crate/context/RoCrateMetadataContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,21 +201,21 @@ public void addToContext(String key, String value) {
201201
}
202202

203203
@Override
204-
public String getValueOf(String key) {
204+
public String readValueOf(String key) {
205205
return Optional.ofNullable(this.contextMap.get(key))
206206
.orElseGet(() -> this.other.get(key));
207207
}
208208

209209
@Override
210-
public Set<String> getImmutableKeys() {
210+
public Set<String> readKeys() {
211211
List<String> merged = new ArrayList<>();
212212
merged.addAll(this.contextMap.keySet());
213213
merged.addAll(this.other.keySet());
214214
return Set.copyOf(merged);
215215
}
216216

217217
@Override
218-
public Map<String, String> getImmutablePairs() {
218+
public Map<String, String> readPairs() {
219219
Map<String, String> merged = new HashMap<>();
220220
merged.putAll(this.contextMap);
221221
merged.putAll(this.other);

src/test/java/edu/kit/datamanager/ro_crate/context/ContextTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,28 +233,28 @@ void testSetDeleteGetPair() {
233233
String key = "key";
234234
String value = "value";
235235
context.addToContext(key, value);
236-
assertEquals(value, context.getValueOf(key));
236+
assertEquals(value, context.readValueOf(key));
237237
context.deleteValuePairFromContext(key);
238-
assertNull(context.getValueOf(key));
238+
assertNull(context.readValueOf(key));
239239
}
240240

241241
@Test
242242
void testReadDeleteGetPair() throws IOException {
243243
setupComplexContext();
244244
String key = "custom";
245245
String value = "_:";
246-
assertEquals(value, context.getValueOf(key));
246+
assertEquals(value, context.readValueOf(key));
247247
context.deleteValuePairFromContext(key);
248-
assertNull(context.getValueOf(key));
248+
assertNull(context.readValueOf(key));
249249
context.addToContext(key, value);
250-
assertEquals(value, context.getValueOf(key));
250+
assertEquals(value, context.readValueOf(key));
251251
}
252252

253253
@Test
254254
void testReadKeys() throws IOException {
255255
setupComplexContext();
256256
var expected = Set.of("custom", "owl", "datacite", "xsd", "rdfs");
257-
var given = context.getImmutableKeys();
257+
var given = context.readKeys();
258258
for (String key : expected) {
259259
assertTrue(given.contains(key), "Key " + key + " not found in the context");
260260
}
@@ -264,7 +264,7 @@ void testReadKeys() throws IOException {
264264
void testReadPairs() throws IOException {
265265
setupComplexContext();
266266
var expected = Set.of("custom", "owl", "datacite", "xsd", "rdfs");
267-
var given = context.getImmutablePairs();
267+
var given = context.readPairs();
268268
var keys = given.keySet();
269269
var values = given.values();
270270
for (String key : expected) {

src/test/java/edu/kit/datamanager/ro_crate/crate/TestRemoveAddContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ void testReadDeleteGetContextPair() {
4343
RoCrate crate = new RoCrateReader(new FolderReader()).readCrate(crateManifestPath);
4444
String key = "custom";
4545
String value = "_:";
46-
assertEquals(value, crate.getMetadataContextValueOf(key));
46+
assertEquals(value, crate.readMetadataContextValueOf(key));
4747
crate.deleteValuePairFromContext(key);
48-
assertNull(crate.getMetadataContextValueOf(key));
48+
assertNull(crate.readMetadataContextValueOf(key));
4949
}
5050

5151
@Test
@@ -54,7 +54,7 @@ void testReadContextKeys() {
5454
crateManifestPath = TestRemoveAddContext.class.getResource(crateManifestPath).getPath();
5555
RoCrate crate = new RoCrateReader(new FolderReader()).readCrate(crateManifestPath);
5656
var expected = Set.of("custom", "owl", "datacite", "xsd", "rdfs");
57-
var given = crate.getMetadataContextKeys();
57+
var given = crate.readMetadataContextKeys();
5858
for (String key : expected) {
5959
assertTrue(given.contains(key), "Key " + key + " not found in the context");
6060
}
@@ -66,7 +66,7 @@ void testReadContextPairs() {
6666
crateManifestPath = TestRemoveAddContext.class.getResource(crateManifestPath).getPath();
6767
RoCrate crate = new RoCrateReader(new FolderReader()).readCrate(crateManifestPath);
6868
var expected = Set.of("custom", "owl", "datacite", "xsd", "rdfs");
69-
var given = crate.getMetadataContextPairs();
69+
var given = crate.readMetadataContextPairs();
7070
var keys = given.keySet();
7171
var values = given.values();
7272
for (String key : expected) {

0 commit comments

Comments
 (0)