Class ObjectSet<T>
- Type Parameters:
T- the type of elements handled by this set
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Set<T>
Set 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 wrap
RDF 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) and AbstractSet.hashCode() operations.
Equality and hashing are dynamic: They depend on the state of the underlying Graph 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
FieldsModifier and TypeFieldDescriptionprotected final Graphprotected final IRIprotected final BlankNodeOrIRIprotected final TermMapping<T>protected final ValueMapping<T> -
Constructor Summary
ConstructorsConstructorDescriptionObjectSet(BlankNodeOrIRI subject, IRI predicate, Graph graph, TermMapping<T> termMapping, ValueMapping<T> valueMapping) Constructs a new dynamic set view over the objects of statements that share a predicate and a subject. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends T> c) voidclear()booleanbooleancontainsAll(Collection<?> c) booleaninthashCode()booleanisEmpty()iterator()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<U> U[]toArray(U[] a) Methods inherited from class java.util.AbstractCollection
toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
spliterator
-
Field Details
-
subject
-
predicate
-
graph
-
termMapping
-
valueMapping
-
-
Constructor Details
-
ObjectSet
public ObjectSet(BlankNodeOrIRI subject, IRI predicate, Graph graph, TermMapping<T> termMapping, 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 statementsgraph- the graph containing the statementstermMapping- a mapping from terms to values used for read operations (useTermMappingsfor common mappings)valueMapping- a mapping from values to nodes used for write operations (useValueMappingsfor common mappings)- Throws:
NullPointerException- if any of the arguments are null
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceSet<T>- Specified by:
sizein classAbstractCollection<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceSet<T>- Overrides:
isEmptyin classAbstractCollection<T>
-
contains
- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceSet<T>- Overrides:
containsin classAbstractCollection<T>
-
iterator
- Specified by:
iteratorin interfaceCollection<T>- Specified by:
iteratorin interfaceIterable<T>- Specified by:
iteratorin interfaceSet<T>- Specified by:
iteratorin classAbstractCollection<T>- Implementation Note:
- Prior to returning the iterator, this implementation consumes (buffers) an underlying
stream of statementswith the currentsubjectandpredicateas well as thevalue mapping functionapplied to each object.
-
toArray
- Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceSet<T>- Overrides:
toArrayin classAbstractCollection<T>
-
toArray
public <U> U[] toArray(U[] a) - Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceSet<T>- Overrides:
toArrayin classAbstractCollection<T>
-
add
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceSet<T>- Overrides:
addin classAbstractCollection<T>
-
remove
- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceSet<T>- Overrides:
removein classAbstractCollection<T>
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceSet<T>- Overrides:
containsAllin classAbstractCollection<T>
-
addAll
- Specified by:
addAllin interfaceCollection<T>- Specified by:
addAllin interfaceSet<T>- Overrides:
addAllin classAbstractCollection<T>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>- Specified by:
retainAllin interfaceSet<T>- Overrides:
retainAllin classAbstractCollection<T>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>- Specified by:
removeAllin interfaceSet<T>- Overrides:
removeAllin classAbstractSet<T>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceSet<T>- Overrides:
clearin classAbstractCollection<T>
-
equals
- Specified by:
equalsin interfaceCollection<T>- Specified by:
equalsin interfaceSet<T>- Overrides:
equalsin classAbstractSet<T>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<T>- Specified by:
hashCodein interfaceSet<T>- Overrides:
hashCodein classAbstractSet<T>
-