Skip to contentPackage: JsonLdContext
JsonLdContext
Coverage
1: package cz.cvut.kbss.jsonld.serialization.context;
2:
3: import cz.cvut.kbss.jsonld.serialization.model.JsonNode;
4:
5: import java.util.Optional;
6:
7: /**
8: * Represents the {@literal @context} JSON-LD attribute.
9: */
10: public interface JsonLdContext {
11:
12: /**
13: * Registers the specified term mapping in this context.
14: * <p>
15: * Typically, the {@code term} would be Java attribute (field) name and {@code iri} would be the IRI to which this
16: * field is mapped.
17: *
18: * @param term Mapped term
19: * @param iri IRI to which the term is mapped
20: */
21: void registerTermMapping(String term, String iri);
22:
23: /**
24: * Registers the specified term mapping in this context.
25: * <p>
26: * Compared to {@link #registerTermMapping(String, String)}, this method allows registering more complex mapping
27: * like language containers or typed literals.
28: *
29: * @param term Mapped term
30: * @param mappedNode Node to which the term is mapped
31: */
32: void registerTermMapping(String term, JsonNode mappedNode);
33:
34: /**
35: * Gets the mapping for the specified term (if it exists).
36: *
37: * @param term Term to get mapping for
38: * @return Optional mapping node
39: */
40: Optional<JsonNode> getTermMapping(String term);
41:
42: /**
43: * Checks whether this JSON-LD context contains mapping for the specified term.
44: *
45: * @param term Term to search mapping for
46: * @return {@code true} if a mapping is already defined for the term, {@code false} otherwise
47: */
48: default boolean hasTermMapping(String term) {
49: return getTermMapping(term).isPresent();
50: }
51: }