Class NodeUpdateData<T>
- Type Parameters:
T
- the type of nodes involved in this update operation
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
FieldsModifier and TypeFieldDescriptionprivate final Map
<QueryResult<T>, Object> The map with the query results whose value has to be changed.private final String
The key of the current update operation.private final Collection
<Object> The collection with the new values to be added.private final Collection
<QueryResult<T>> The collection with query results about the nodes to be removed. -
Constructor Summary
ConstructorsConstructorDescriptionNodeUpdateData
(Map<QueryResult<T>, Object> changedValues, Collection<Object> newValues, Collection<QueryResult<T>> removedNodes, String key) Creates a new instance ofNodeUpdateData
and initializes all its properties. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> Collection
<T> copyCollection
(Collection<? extends T> col) Creates an unmodifiable defensive copy of the passed in collection with may be null.private static <K,
V> Map <K, V> Creates an unmodifiable defensive copy of the passed in map which may be null.Gets an unmodifiable map with the values to be changed.getKey()
Gets the key for this update operation.Gets a collection with the values to be newly added.Adds a collection with the nodes to be removed.
-
Field Details
-
changedValues
The map with the query results whose value has to be changed. -
newValues
The collection with the new values to be added. -
removedNodes
The collection with query results about the nodes to be removed. -
key
The key of the current update operation.
-
-
Constructor Details
-
NodeUpdateData
public NodeUpdateData(Map<QueryResult<T>, Object> changedValues, Collection<Object> newValues, Collection<QueryResult<T>> removedNodes, String key) Creates a new instance ofNodeUpdateData
and initializes all its properties. All passed in collections are optional and can be null.- Parameters:
changedValues
- the map defining the changed valuesnewValues
- the collection with the new valuesremovedNodes
- the collection with the nodes to be removedkey
- the key of the update operation
-
-
Method Details
-
copyCollection
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
Creates an unmodifiable defensive copy of the passed in map which may be null.- Type Parameters:
K
- the type of the keys involvedV
- the type of the values involved- Parameters:
map
- the map to be copied- Returns:
- the unmodifiable copy
-
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
Gets the key for this update operation.- Returns:
- the key for this operation
-
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
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
-