Class QuadImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int hashCode  
      private java.util.UUID salt  
      private org.eclipse.rdf4j.model.Statement statement  
    • Constructor Summary

      Constructors 
      Constructor Description
      QuadImpl​(org.eclipse.rdf4j.model.Statement statement, java.util.UUID salt)  
    • Field Detail

      • hashCode

        private transient int hashCode
      • salt

        private final java.util.UUID salt
      • statement

        private final org.eclipse.rdf4j.model.Statement statement
    • Constructor Detail

      • QuadImpl

        QuadImpl​(org.eclipse.rdf4j.model.Statement statement,
                 java.util.UUID salt)
    • Method Detail

      • asStatement

        public org.eclipse.rdf4j.model.Statement asStatement()
        Description copied from interface: RDF4JTripleLike
        Return the corresponding RDF4J Statement.
        Specified by:
        asStatement in interface RDF4JTripleLike
        Returns:
        The corresponding RDF4J Statement.
      • asTriple

        public Triple asTriple()
        Description copied from interface: Quad
        Adapt this Quad to a Triple.

        The returned Triple will have equivalent values returned from the methods TripleLike.getSubject(), TripleLike.getPredicate() and TripleLike.getObject().

        The returned Triple MUST NOT be Quad.equals(Object) to this Quad, even if this quad has a default graph Quad.getGraphName() value of Optional.empty(), but MUST follow the Triple.equals(Object) semantics. This means that the following MUST be true:

         Quad q1, q2;
         if (q1.equals(q2)) {
             assert (q1.asTriple().equals(q2.asTriple()));
         } else if (q1.asTriple().equals(q2.asTriple())) {
             assert (q1.getSubject().equals(q2.getSubject()));
             assert (q1.getPredicate().equals(q2.getPredicate()));
             assert (q1.getObject().equals(q2.getObject()));
             assert (!q1.getGraphName().equals(q2.getGraphName()));
         }
         
        The default implementation of this method return a proxy Triple instance that keeps a reference to this Quad to call the underlying TripleLike methods, but supplies a Triple compatible implementation of Triple.equals(Object) and Triple.hashCode(). Implementations may override this method, e.g. for a more efficient solution.
        Specified by:
        asTriple in interface Quad
        Returns:
        A Triple that contains the same TripleLike properties as this Quad.
      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from interface: Quad
        Check it this Quad is equal to another Quad.

        Two Quads are equal if and only if their Quad.getGraphName(), Quad.getSubject(), Quad.getPredicate() and Quad.getObject() are equal.

        Implementations MUST also override Quad.hashCode() so that two equal Quads produce the same hash code.

        Note that a Quad MUST NOT be equal to a Triple, even if this Quad's Quad.getGraphName() is Optional.empty(). To test triple-like equivalence, callers can use:

         Quad q1;
         Triple t2;
         q1.asTriple().equals(t2));
         
        Specified by:
        equals in interface Quad
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - Another object
        Returns:
        true if other is a Quad and is equal to this
        See Also:
        Object.equals(Object)
      • getGraphName

        public java.util.Optional<BlankNodeOrIRI> getGraphName()
        Description copied from interface: Quad
        The graph name (graph label) of this quad, if present. If Optional.isPresent(), then the Optional.get() is either a BlankNode or an IRI, indicating the graph name of this Quad. If the graph name is not present, e.g. the value is Optional.empty(), it indicates that this Quad is in the default graph.
        Specified by:
        getGraphName in interface Quad
        Specified by:
        getGraphName in interface QuadLike<BlankNodeOrIRI>
        Returns:
        If Optional.isPresent(), the graph name BlankNodeOrIRI of this quad, otherwise Optional.empty(), indicating the default graph.
        See Also:
        RDF- 1.1 Dataset
      • hashCode

        public int hashCode()
        Description copied from interface: Quad
        Calculate a hash code for this Quad.

        The returned hash code MUST be equal to the result of Objects.hash(Object...) with the arguments Quad.getSubject(), Quad.getPredicate(), Quad.getObject(), Quad.getGraphName().

        This method MUST be implemented in conjunction with Quad.equals(Object) so that two equal Quads produce the same hash code.

        Specified by:
        hashCode in interface Quad
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code value for this Quad.
        See Also:
        Object.hashCode(), Objects.hash(Object...)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object