Class NodeUpdateData<T>

  • Type Parameters:
    T - the type of nodes involved in this update operation

    public class NodeUpdateData<T>
    extends java.lang.Object

    A simple data class used by node models to store parameters of an update operation.

    The Configuration interface provides a method for setting the value of a given key. The passed in value can be a single object or a collection of values. This makes an update operation rather complicated because a collection of query results selected by the passed in key has to be matched to another collection of values - and both collections can have different sizes. Therefore, an update operation may involve changing of existing nodes, adding new nodes (if there are more values than currently existing nodes), and removing nodes (if there are more existing nodes than provided values). This class collects all this information making it possible to actually perform the update based on a passed in instance.

    Since:
    2.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<QueryResult<T>,​java.lang.Object> changedValues
      The map with the query results whose value has to be changed.
      private java.lang.String key
      The key of the current update operation.
      private java.util.Collection<java.lang.Object> newValues
      The collection with the new values to be added.
      private java.util.Collection<QueryResult<T>> removedNodes
      The collection with query results about the nodes to be removed.
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeUpdateData​(java.util.Map<QueryResult<T>,​java.lang.Object> changedValues, java.util.Collection<java.lang.Object> newValues, java.util.Collection<QueryResult<T>> removedNodes, java.lang.String key)
      Creates a new instance of NodeUpdateData and initializes all its properties.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static <T> java.util.Collection<T> copyCollection​(java.util.Collection<? extends T> col)
      Creates an unmodifiable defensive copy of the passed in collection with may be null.
      private static <K,​V>
      java.util.Map<K,​V>
      copyMap​(java.util.Map<? extends K,​? extends V> map)
      Creates an unmodifiable defensive copy of the passed in map which may be null.
      java.util.Map<QueryResult<T>,​java.lang.Object> getChangedValues()
      Gets an unmodifiable map with the values to be changed.
      java.lang.String getKey()
      Gets the key for this update operation.
      java.util.Collection<java.lang.Object> getNewValues()
      Gets a collection with the values to be newly added.
      java.util.Collection<QueryResult<T>> getRemovedNodes()
      Adds a collection with the nodes to be removed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • changedValues

        private final java.util.Map<QueryResult<T>,​java.lang.Object> changedValues
        The map with the query results whose value has to be changed.
      • newValues

        private final java.util.Collection<java.lang.Object> newValues
        The collection with the new values to be added.
      • removedNodes

        private final java.util.Collection<QueryResult<T>> removedNodes
        The collection with query results about the nodes to be removed.
      • key

        private final java.lang.String key
        The key of the current update operation.
    • Constructor Detail

      • NodeUpdateData

        public NodeUpdateData​(java.util.Map<QueryResult<T>,​java.lang.Object> changedValues,
                              java.util.Collection<java.lang.Object> newValues,
                              java.util.Collection<QueryResult<T>> removedNodes,
                              java.lang.String key)
        Creates a new instance of NodeUpdateData and initializes all its properties. All passed in collections are optional and can be null.
        Parameters:
        changedValues - the map defining the changed values
        newValues - the collection with the new values
        removedNodes - the collection with the nodes to be removed
        key - the key of the update operation
    • Method Detail

      • copyCollection

        private static <T> java.util.Collection<T> copyCollection​(java.util.Collection<? extends T> col)
        Creates an unmodifiable defensive copy of the passed in collection with may be null.
        Type Parameters:
        T - the element type of the collection
        Parameters:
        col - the collection to be copied
        Returns:
        the unmodifiable copy
      • copyMap

        private static <K,​V> java.util.Map<K,​V> copyMap​(java.util.Map<? extends K,​? extends V> map)
        Creates an unmodifiable defensive copy of the passed in map which may be null.
        Type Parameters:
        K - the type of the keys involved
        V - the type of the values involved
        Parameters:
        map - the map to be copied
        Returns:
        the unmodifiable copy
      • getChangedValues

        public java.util.Map<QueryResult<T>,​java.lang.Object> getChangedValues()
        Gets an unmodifiable map with the values to be changed. The keys of the map are the query results for the nodes affected, the values are the new values to be assigned to these nodes.
        Returns:
        the map with values to be changed
      • getKey

        public java.lang.String getKey()
        Gets the key for this update operation.
        Returns:
        the key for this operation
      • getNewValues

        public java.util.Collection<java.lang.Object> getNewValues()
        Gets a collection with the values to be newly added. For these values new nodes have to be created and added under the key stored in this object.
        Returns:
        the collection with new values
      • getRemovedNodes

        public java.util.Collection<QueryResult<T>> getRemovedNodes()
        Adds a collection with the nodes to be removed. These nodes are no longer needed and have to be removed from the node model processing this request.
        Returns:
        the collection with nodes to be removed