Skip to content

Commit 597568d

Browse files
committed
refactor: rename context accessors to use "get" prefix for consistency
1 parent d5af790 commit 597568d

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 readMetadataContextValueOf(String key);
60+
String getMetadataContextValueOf(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> readMetadataContextKeys();
66+
Set<String> getMetadataContextKeys();
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> readMetadataContextPairs();
72+
Map<String, String> getMetadataContextPairs();
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 readMetadataContextValueOf(String key) {
66-
return this.metadataContext.readValueOf(key);
65+
public String getMetadataContextValueOf(String key) {
66+
return this.metadataContext.getValueOf(key);
6767
}
6868

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

7474
@Override
75-
public Map<String, String> readMetadataContextPairs() {
76-
return this.metadataContext.readPairs();
75+
public Map<String, String> getMetadataContextPairs() {
76+
return this.metadataContext.getPairs();
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 readValueOf(String key);
33+
String getValueOf(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> readKeys();
39+
Set<String> getKeys();
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> readPairs();
45+
Map<String, String> getPairs();
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 readValueOf(String key) {
204+
public String getValueOf(String key) {
205205
return Optional.ofNullable(this.contextMap.get(key))
206206
.orElseGet(() -> this.other.get(key));
207207
}
208208

209209
@Override
210-
public Set<String> readKeys() {
210+
public Set<String> getKeys() {
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> readPairs() {
218+
public Map<String, String> getPairs() {
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
@@ -238,26 +238,26 @@ void testSetDeleteGetPair() {
238238
String key = "key";
239239
String value = "value";
240240
context.addToContext(key, value);
241-
assertEquals(value, context.readValueOf(key));
241+
assertEquals(value, context.getValueOf(key));
242242
context.deleteValuePairFromContext(key);
243-
assertNull(context.readValueOf(key));
243+
assertNull(context.getValueOf(key));
244244
}
245245

246246
@Test
247247
void testReadDeleteGetPair() {
248248
String key = "custom";
249249
String value = "_:";
250-
assertEquals(value, this.complexContext.readValueOf(key));
250+
assertEquals(value, this.complexContext.getValueOf(key));
251251
this.complexContext.deleteValuePairFromContext(key);
252-
assertNull(this.complexContext.readValueOf(key));
252+
assertNull(this.complexContext.getValueOf(key));
253253
this.complexContext.addToContext(key, value);
254-
assertEquals(value, this.complexContext.readValueOf(key));
254+
assertEquals(value, this.complexContext.getValueOf(key));
255255
}
256256

257257
@Test
258258
void testReadKeys() {
259259
var expected = Set.of("custom", "owl", "datacite", "xsd", "rdfs");
260-
var given = this.complexContext.readKeys();
260+
var given = this.complexContext.getKeys();
261261
for (String key : expected) {
262262
assertTrue(given.contains(key), "Key " + key + " not found in the context");
263263
}
@@ -268,7 +268,7 @@ void testReadKeys() {
268268
@Test
269269
void testReadPairs() {
270270
var expected = Set.of("custom", "owl", "datacite", "xsd", "rdfs");
271-
var given = this.complexContext.readPairs();
271+
var given = this.complexContext.getPairs();
272272
var keys = given.keySet();
273273
var values = given.values();
274274
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
@@ -50,15 +50,15 @@ void testAddRemoveUrl() throws JsonProcessingException {
5050
void testReadDeleteGetContextPair() {
5151
String key = "custom";
5252
String value = "_:";
53-
assertEquals(value, this.crateWithComplexContext.readMetadataContextValueOf(key));
53+
assertEquals(value, this.crateWithComplexContext.getMetadataContextValueOf(key));
5454
this.crateWithComplexContext.deleteValuePairFromContext(key);
55-
assertNull(this.crateWithComplexContext.readMetadataContextValueOf(key));
55+
assertNull(this.crateWithComplexContext.getMetadataContextValueOf(key));
5656
}
5757

5858
@Test
5959
void testReadContextKeys() {
6060
var expected = Set.of("custom", "owl", "datacite", "xsd", "rdfs");
61-
var given = this.crateWithComplexContext.readMetadataContextKeys();
61+
var given = this.crateWithComplexContext.getMetadataContextKeys();
6262
for (String key : expected) {
6363
assertTrue(given.contains(key), "Key " + key + " not found in the context");
6464
}
@@ -69,7 +69,7 @@ void testReadContextKeys() {
6969
@Test
7070
void testReadContextPairs() {
7171
var expected = Set.of("custom", "owl", "datacite", "xsd", "rdfs");
72-
var given = this.crateWithComplexContext.readMetadataContextPairs();
72+
var given = this.crateWithComplexContext.getMetadataContextPairs();
7373
var keys = given.keySet();
7474
var values = given.values();
7575
for (String key : expected) {

0 commit comments

Comments
 (0)