Package com.inrupt.rdf.wrapping.commons
Class WrapperBlankNodeOrIRI
java.lang.Object
com.inrupt.rdf.wrapping.commons.WrapperBlankNodeOrIRI
- All Implemented Interfaces:
BlankNodeOrIRI
,RDFTerm
- Direct Known Subclasses:
WrapperBlankNode
,WrapperIRI
A wrapper for IRI and blank node terms which contains methods that aid authoring wrapping classes.
All methods require a predicate and a value mapping function.
This table details the behavior of singular getter helper methods depending on the number of matching statements in the underlying graph:
┌───────────────┬───────┬────────┬────────┐ │ │ 0 │ 1 │ >1 │ ├───────────────┼───────┼────────┼────────┤ │ anyOrNull │ null │ single │ random │ │ anyOrThrow │ throw │ single │ random │ │ singleOrNull │ null │ single │ throw │ │ singleOrThrow │ throw │ single │ throw │ └───────────────┴───────┴────────┴────────┘
This table details the behavior of plural getter helper methods in terms of reflecting changes to the underlying graph after calling them:
┌─────────────────┬─────────┐ │ objects │ dynamic │ │ objectStream │ static │ │ objectIterator │ static │ │ objectsReadOnly │ static │ └─────────────────┴─────────┘
This table details the behavior of setter helper methods in terms of effect on existing statements in the underlying graph and given values:
┌───────────────────┬──────────┬────────────┐ │ │ existing │ null value │ ├───────────────────┼──────────┼────────────┤ │ overwrite │ remove │ throw │ │ overwriteNullable │ remove │ ignore │ │ add │ leave │ throw │ └───────────────────┴──────────┴────────────┘
- Author:
- Samu Lang
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
WrapperBlankNodeOrIRI
(Graph graph) Create a new subject node with a backingGraph
object. -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> void
add
(IRI p, Iterable<T> v, TermMapping<T> m) An additive converting singular setter helper for expected cardinality0..*
.protected <T> void
add
(IRI p, T v, TermMapping<T> m) An additive converting singular setter helper for expected cardinality0..*
.protected <T> T
anyOrNull
(IRI p, ValueMapping<T> m) A converting singular getter helper for expected cardinality0..1
that ignores overflow.protected <T> T
anyOrThrow
(IRI p, ValueMapping<T> m) A converting singular getter helper for expected cardinality1..1
that ignores overflow.protected <T> Iterator<T>
objectIterator
(IRI p, ValueMapping<T> m) A static converting plural getter helper for expected cardinality0..*
.protected <T> Set<T>
objects
(IRI p, TermMapping<T> tm, ValueMapping<T> vm) A dynamic converting plural getter helper for expected cardinality0..*
.protected <T> Set<T>
objectsReadOnly
(IRI p, ValueMapping<T> m) A static converting plural getter helper for expected cardinality0..*
.protected <T> Stream<T>
objectStream
(IRI p, ValueMapping<T> m) A static converting plural getter helper for expected cardinality0..*
.protected <T> void
overwrite
(IRI p, Iterable<T> v, TermMapping<T> m) A destructive converting plural setter helper for expected cardinality1..*
.protected <T> void
overwrite
(IRI p, T v, TermMapping<T> m) A destructive converting singular setter helper for expected cardinality1..1
.protected <T> void
overwriteNullable
(IRI p, Iterable<T> v, TermMapping<T> m) A destructive converting plural setter helper for expected cardinality0..*
.protected <T> void
overwriteNullable
(IRI p, T v, TermMapping<T> m) A destructive converting singular setter helper for expected cardinality0..1
.protected <T> T
singleOrNull
(IRI p, ValueMapping<T> m) A converting singular getter helper for expected cardinality0..1
that forbids overflow.protected <T> T
singleOrThrow
(IRI p, ValueMapping<T> m) A converting singular getter helper for expected cardinality1..1
that forbids overflow.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.commons.rdf.api.RDFTerm
equals, hashCode, ntriplesString
-
Field Details
-
graph
The internal wrapped graph object.
-
-
Constructor Details
-
WrapperBlankNodeOrIRI
Create a new subject node with a backingGraph
object.- Parameters:
graph
- The wrapped graph, may not benull
-
-
Method Details
-
anyOrNull
A converting singular getter helper for expected cardinality0..1
that ignores overflow.- Type Parameters:
T
- the type of values returned the type of values returned- Parameters:
p
- the predicate to querym
- the mapping applied to result terms- Returns:
- the converted object of an arbitrary statement with this subject and the given predicate or null if there are no such statements
-
anyOrThrow
A converting singular getter helper for expected cardinality1..1
that ignores overflow.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to querym
- the mapping applied to result terms- Returns:
- the converted object of an arbitrary statement with this subject and the given predicate
- Throws:
IllegalStateException
- if there are no such statements
-
singleOrNull
A converting singular getter helper for expected cardinality0..1
that forbids overflow.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to querym
- the mapping applied to result terms- Returns:
- the converted object of the only statement with this subject and the given predicate, or null if there is no such statement
- Throws:
IllegalStateException
- if there are multiple such statements
-
singleOrThrow
A converting singular getter helper for expected cardinality1..1
that forbids overflow.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to querym
- the mapping applied to result terms- Returns:
- the converted object of the only statement with this subject and the given predicate
- Throws:
IllegalStateException
- if there are no such statementsIllegalStateException
- if there are multiple such statements
-
objectIterator
A static converting plural getter helper for expected cardinality0..*
.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to querym
- the mapping applied to result terms- Returns:
- the converted objects of statements with this subject and the given predicate
- Implementation Note:
- Prior to returning the iterator, this implementation consumes (buffers) an underlying
stream of statements
with the predicatep
and the mapping functionm
applied to each object.
-
objectsReadOnly
A static converting plural getter helper for expected cardinality0..*
.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to querym
- the mapping applied to result terms- Returns:
- a static set view over converted objects of statements with this subject and the given predicate
-
objects
A dynamic converting plural getter helper for expected cardinality0..*
.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to querytm
- the input mapping to apply to valuesvm
- the output mapping to apply to terms- Returns:
- a dynamic set view over converted objects of statements with this subject and the given predicate
-
objectStream
A static converting plural getter helper for expected cardinality0..*
.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to querym
- the mapping applied to result terms- Returns:
- a static stream of converted objects of statements with this subject and the given predicate
-
overwrite
A destructive converting singular setter helper for expected cardinality1..1
.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to queryv
- the value to assert as object in the graphm
- the mapping applied to the value- Throws:
NullPointerException
- if the given value isnull
-
overwrite
A destructive converting plural setter helper for expected cardinality1..*
.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to queryv
- the values to assert as objects in the graphm
- the mapping applied to the value- Throws:
NullPointerException
- if the given value isnull
NullPointerException
- if the given value containsnull
elements
-
overwriteNullable
A destructive converting plural setter helper for expected cardinality0..*
.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to queryv
- the values to assert as objects in the graphm
- the mapping applied to the value- Throws:
NullPointerException
- if the given value is notnull
and containsnull
elements
-
overwriteNullable
A destructive converting singular setter helper for expected cardinality0..1
.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to queryv
- the value to assert as object in the graphm
- the mapping applied to the value
-
add
An additive converting singular setter helper for expected cardinality0..*
.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to queryv
- the value to assert as object in the graphm
- the mapping applied to the value- Throws:
NullPointerException
- if the given value isnull
-
add
An additive converting singular setter helper for expected cardinality0..*
.- Type Parameters:
T
- the type of values returned- Parameters:
p
- the predicate to queryv
- the values to assert as objects in the graphm
- the mapping applied to the value- Throws:
NullPointerException
- if the given value isnull
NullPointerException
- if the given value containsnull
elements
-