Class SimpleBindingSet

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<Binding>, BindingSet

    public class SimpleBindingSet
    extends java.lang.Object
    implements BindingSet
    A simple binding set tuned for the use case that the ShaclSail has.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleBindingSet​(java.util.Set<java.lang.String> bindingNamesSet, java.util.List<java.lang.String> varNamesList, java.util.List<Value> values)  
      SimpleBindingSet​(java.util.Set<java.lang.String> bindingNamesSet, Binding[] bindings)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object other)
      Compares a BindingSet object to another object.
      Binding getBinding​(java.lang.String bindingName)
      Gets the binding with the specified name from this BindingSet.
      java.util.Set<java.lang.String> getBindingNames()
      Gets the names of the bindings in this BindingSet.
      Value getValue​(java.lang.String bindingName)
      Gets the value of the binding with the specified name from this BindingSet.
      boolean hasBinding​(java.lang.String bindingName)
      Checks whether this BindingSet has a binding with the specified name.
      int hashCode()
      The hash code of a binding is defined as the bit-wise XOR of the hash codes of its bindings:
      boolean isEmpty()  
      java.util.Iterator<Binding> iterator()
      Creates an iterator over the bindings in this BindingSet.
      int size()
      Returns the number of bindings in this BindingSet.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • bindingNamesSet

        private final java.util.Set<java.lang.String> bindingNamesSet
      • bindings

        private final Binding[] bindings
      • cachedHashCode

        private int cachedHashCode
    • Constructor Detail

      • SimpleBindingSet

        public SimpleBindingSet​(java.util.Set<java.lang.String> bindingNamesSet,
                                java.util.List<java.lang.String> varNamesList,
                                java.util.List<Value> values)
      • SimpleBindingSet

        public SimpleBindingSet​(java.util.Set<java.lang.String> bindingNamesSet,
                                Binding[] bindings)
    • Method Detail

      • iterator

        public java.util.Iterator<Binding> iterator()
        Description copied from interface: BindingSet
        Creates an iterator over the bindings in this BindingSet. This only returns bindings with non-null values. An implementation is free to return the bindings in arbitrary order.
        Specified by:
        iterator in interface BindingSet
        Specified by:
        iterator in interface java.lang.Iterable<Binding>
      • getBindingNames

        public java.util.Set<java.lang.String> getBindingNames()
        Description copied from interface: BindingSet
        Gets the names of the bindings in this BindingSet.
        Specified by:
        getBindingNames in interface BindingSet
        Returns:
        A set of binding names.
      • getBinding

        public Binding getBinding​(java.lang.String bindingName)
        Description copied from interface: BindingSet
        Gets the binding with the specified name from this BindingSet.
        Specified by:
        getBinding in interface BindingSet
        Parameters:
        bindingName - The name of the binding.
        Returns:
        The binding with the specified name, or null if there is no such binding in this BindingSet.
      • hasBinding

        public boolean hasBinding​(java.lang.String bindingName)
        Description copied from interface: BindingSet
        Checks whether this BindingSet has a binding with the specified name.
        Specified by:
        hasBinding in interface BindingSet
        Parameters:
        bindingName - The name of the binding.
        Returns:
        true if this BindingSet has a binding with the specified name, false otherwise.
      • getValue

        public Value getValue​(java.lang.String bindingName)
        Description copied from interface: BindingSet
        Gets the value of the binding with the specified name from this BindingSet.
        Specified by:
        getValue in interface BindingSet
        Parameters:
        bindingName - The name of the binding.
        Returns:
        The value of the binding with the specified name, or null if there is no such binding in this BindingSet.
      • size

        public int size()
        Description copied from interface: BindingSet
        Returns the number of bindings in this BindingSet.
        Specified by:
        size in interface BindingSet
        Returns:
        The number of bindings in this BindingSet.
      • hashCode

        public int hashCode()
        Description copied from interface: BindingSet
        The hash code of a binding is defined as the bit-wise XOR of the hash codes of its bindings:
         int hashCode = 0;
        
         for (Binding binding : this) {
                hashCode ˆ= binding.getName().hashCode() ˆ binding.getValue().hashCode();
         }
         

        Note: the calculated hash code intentionally does not depend on the order in which the bindings are iterated over.

        Specified by:
        hashCode in interface BindingSet
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        A hash code for the BindingSet.
      • equals

        public boolean equals​(java.lang.Object other)
        Description copied from interface: BindingSet
        Compares a BindingSet object to another object.
        Specified by:
        equals in interface BindingSet
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - The object to compare this binding to.
        Returns:
        true if the other object is an instance of BindingSet and it contains the same set of bindings (disregarding order), false otherwise.
      • toString

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