Class 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 the 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
    • 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 statements
        predicate - the predicate node shared by all statements
        model - the underlying RDF model from which the data is accessed
        nodeMapping - a mapping from terms to values used for read operations (use TermMappings for common mappings)
        valueMapping - a mapping from values to nodes used for write operations (use ValueMappings for common mappings)
        Throws:
        NullPointerException - if any of the arguments are null