Class ObjectSet<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<T>
-
- com.inrupt.rdf.wrapping.commons.ObjectSet<T>
-
- com.inrupt.rdf.wrapping.rdf4j.ObjectSet<T>
-
- Type Parameters:
T
- the type of elements handled by this set
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,Set<T>
public class ObjectSet<T> extends ObjectSet<T>
This class implements theSet
interface as a dynamic, mutable view over an RDF predicate-object list (statements that share a subject and a predicate). It is intended for use in classes that wrapRDF nodes
for strongly typed convenience mapping.This set does not permit
null
elements.The order of elements returned by this implementation is not guaranteed as it depends on the ordering of query results in the underlying
Graph
. This reflects the unordered nature of RDF graphs.The synchronization characteristics and time complexity of this implementation are those of the underlying
Graph
implementation. It could well be that read and write operations on instances of this class result in expensive IO operations. Even simple iteration is most likely to be much less performant than what callers expect from other Java collections.The iterators returned by this implementation do not support the
Iterator.remove()
operation.This implementation uses the
AbstractSet.equals(Object)
andAbstractSet.hashCode()
operations. Equality and hashing are dynamic: They depend on the state of the underlyingGraph
at the time of calling and are not fixed when creating the instance.Example: Given a node wrapper
N
, instances of this class can be used to make read/write strongly typed set properties.public class N { public Set<String> getType { return new PredicateObjectSet<>( this, RDF.type, g, NodeMappings::asIriResource, ValueMappings::iriAsString ); } }
- Author:
- Samu Lang
-
-
Field Summary
-
Fields inherited from class com.inrupt.rdf.wrapping.commons.ObjectSet
graph, predicate, subject, termMapping, valueMapping
-
-
Constructor Summary
Constructors Constructor Description ObjectSet(org.eclipse.rdf4j.model.Value subject, org.eclipse.rdf4j.model.Value predicate, org.eclipse.rdf4j.model.Model model, RdfValueMapping<T> nodeMapping, ValueMapping<T> valueMapping)
Constructs a new dynamic set view over the objects of statements that share a predicate and a subject.
-
Method Summary
-
Methods inherited from class com.inrupt.rdf.wrapping.commons.ObjectSet
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
-
Methods inherited from class java.util.AbstractCollection
toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
spliterator
-
-
-
-
Constructor Detail
-
ObjectSet
public ObjectSet(org.eclipse.rdf4j.model.Value subject, org.eclipse.rdf4j.model.Value predicate, org.eclipse.rdf4j.model.Model model, RdfValueMapping<T> nodeMapping, ValueMapping<T> valueMapping)
Constructs a new dynamic set view over the objects of statements that share a predicate and a subject.- Parameters:
subject
- the subject node shared by all statementspredicate
- the predicate node shared by all statementsmodel
- the underlying RDF model from which the data is accessednodeMapping
- a mapping from terms to values used for read operations (useTermMappings
for common mappings)valueMapping
- a mapping from values to nodes used for write operations (useValueMappings
for common mappings)- Throws:
NullPointerException
- if any of the arguments are null
-
-