You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/09/27 22:24:26 UTC
svn commit: r1842194 [13/34] - in /commons/proper/configuration/trunk/src:
main/java/org/apache/commons/configuration2/
main/java/org/apache/commons/configuration2/beanutils/
main/java/org/apache/commons/configuration2/builder/
main/java/org/apache/com...
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/InMemoryNodeModel.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/InMemoryNodeModel.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/InMemoryNodeModel.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/InMemoryNodeModel.java Thu Sep 27 22:24:23 2018
@@ -80,7 +80,7 @@ public class InMemoryNodeModel implement
*
* @param root the new root node for this model
*/
- public InMemoryNodeModel(ImmutableNode root)
+ public InMemoryNodeModel(final ImmutableNode root)
{
structure =
new AtomicReference<>(
@@ -116,8 +116,8 @@ public class InMemoryNodeModel implement
}
@Override
- public void addProperty(String key, Iterable<?> values,
- NodeKeyResolver<ImmutableNode> resolver)
+ public void addProperty(final String key, final Iterable<?> values,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
addProperty(key, null, values, resolver);
}
@@ -136,7 +136,7 @@ public class InMemoryNodeModel implement
* @param resolver the {@code NodeKeyResolver}
* @throws ConfigurationRuntimeException if the selector cannot be resolved
*/
- public void addProperty(final String key, NodeSelector selector,
+ public void addProperty(final String key, final NodeSelector selector,
final Iterable<?> values,
final NodeKeyResolver<ImmutableNode> resolver)
{
@@ -145,7 +145,7 @@ public class InMemoryNodeModel implement
updateModel(new TransactionInitializer()
{
@Override
- public boolean initTransaction(ModelTransaction tx)
+ public boolean initTransaction(final ModelTransaction tx)
{
initializeAddTransaction(tx, key, values, resolver);
return true;
@@ -155,8 +155,8 @@ public class InMemoryNodeModel implement
}
@Override
- public void addNodes(String key, Collection<? extends ImmutableNode> nodes,
- NodeKeyResolver<ImmutableNode> resolver)
+ public void addNodes(final String key, final Collection<? extends ImmutableNode> nodes,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
addNodes(key, null, nodes, resolver);
}
@@ -175,7 +175,7 @@ public class InMemoryNodeModel implement
* @param resolver the {@code NodeKeyResolver}
* @throws ConfigurationRuntimeException if the selector cannot be resolved
*/
- public void addNodes(final String key, NodeSelector selector,
+ public void addNodes(final String key, final NodeSelector selector,
final Collection<? extends ImmutableNode> nodes,
final NodeKeyResolver<ImmutableNode> resolver)
{
@@ -184,9 +184,9 @@ public class InMemoryNodeModel implement
updateModel(new TransactionInitializer()
{
@Override
- public boolean initTransaction(ModelTransaction tx)
+ public boolean initTransaction(final ModelTransaction tx)
{
- List<QueryResult<ImmutableNode>> results =
+ final List<QueryResult<ImmutableNode>> results =
resolver.resolveKey(tx.getQueryRoot(), key,
tx.getCurrentData());
if (results.size() == 1)
@@ -199,14 +199,14 @@ public class InMemoryNodeModel implement
}
else
{
- NodeAddData<ImmutableNode> addData =
+ final NodeAddData<ImmutableNode> addData =
resolver.resolveAddKey(tx.getQueryRoot(), key,
tx.getCurrentData());
if (addData.isAttribute())
{
throw attributeKeyException(key);
}
- ImmutableNode newNode =
+ final ImmutableNode newNode =
new ImmutableNode.Builder(nodes.size())
.name(addData.getNewNodeName())
.addChildren(nodes).create();
@@ -220,8 +220,8 @@ public class InMemoryNodeModel implement
}
@Override
- public void setProperty(String key, Object value,
- NodeKeyResolver<ImmutableNode> resolver)
+ public void setProperty(final String key, final Object value,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
setProperty(key, null, value, resolver);
}
@@ -240,16 +240,16 @@ public class InMemoryNodeModel implement
* @param resolver the {@code NodeKeyResolver}
* @throws ConfigurationRuntimeException if the selector cannot be resolved
*/
- public void setProperty(final String key, NodeSelector selector,
+ public void setProperty(final String key, final NodeSelector selector,
final Object value, final NodeKeyResolver<ImmutableNode> resolver)
{
updateModel(new TransactionInitializer()
{
@Override
- public boolean initTransaction(ModelTransaction tx)
+ public boolean initTransaction(final ModelTransaction tx)
{
boolean added = false;
- NodeUpdateData<ImmutableNode> updateData =
+ final NodeUpdateData<ImmutableNode> updateData =
resolver.resolveUpdateKey(tx.getQueryRoot(), key,
value, tx.getCurrentData());
if (!updateData.getNewValues().isEmpty())
@@ -258,10 +258,10 @@ public class InMemoryNodeModel implement
updateData.getNewValues(), resolver);
added = true;
}
- boolean cleared =
+ final boolean cleared =
initializeClearTransaction(tx,
updateData.getRemovedNodes());
- boolean updated =
+ final boolean updated =
initializeUpdateTransaction(tx,
updateData.getChangedValues());
return added || cleared || updated;
@@ -276,8 +276,8 @@ public class InMemoryNodeModel implement
* objects for the elements to be removed from the model.
*/
@Override
- public List<QueryResult<ImmutableNode>> clearTree(String key,
- NodeKeyResolver<ImmutableNode> resolver)
+ public List<QueryResult<ImmutableNode>> clearTree(final String key,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
return clearTree(key, null, resolver);
}
@@ -297,22 +297,22 @@ public class InMemoryNodeModel implement
* @throws ConfigurationRuntimeException if the selector cannot be resolved
*/
public List<QueryResult<ImmutableNode>> clearTree(final String key,
- NodeSelector selector, final NodeKeyResolver<ImmutableNode> resolver)
+ final NodeSelector selector, final NodeKeyResolver<ImmutableNode> resolver)
{
final List<QueryResult<ImmutableNode>> removedElements =
new LinkedList<>();
updateModel(new TransactionInitializer()
{
@Override
- public boolean initTransaction(ModelTransaction tx)
+ public boolean initTransaction(final ModelTransaction tx)
{
boolean changes = false;
- TreeData currentStructure = tx.getCurrentData();
- List<QueryResult<ImmutableNode>> results = resolver.resolveKey(
+ final TreeData currentStructure = tx.getCurrentData();
+ final List<QueryResult<ImmutableNode>> results = resolver.resolveKey(
tx.getQueryRoot(), key, currentStructure);
removedElements.clear();
removedElements.addAll(results);
- for (QueryResult<ImmutableNode> result : results)
+ for (final QueryResult<ImmutableNode> result : results)
{
if (result.isAttributeResult())
{
@@ -345,8 +345,8 @@ public class InMemoryNodeModel implement
* state, it is removed from the model.
*/
@Override
- public void clearProperty(String key,
- NodeKeyResolver<ImmutableNode> resolver)
+ public void clearProperty(final String key,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
clearProperty(key, null, resolver);
}
@@ -364,15 +364,15 @@ public class InMemoryNodeModel implement
* @param resolver the {@code NodeKeyResolver}
* @throws ConfigurationRuntimeException if the selector cannot be resolved
*/
- public void clearProperty(final String key, NodeSelector selector,
+ public void clearProperty(final String key, final NodeSelector selector,
final NodeKeyResolver<ImmutableNode> resolver)
{
updateModel(new TransactionInitializer()
{
@Override
- public boolean initTransaction(ModelTransaction tx)
+ public boolean initTransaction(final ModelTransaction tx)
{
- List<QueryResult<ImmutableNode>> results =
+ final List<QueryResult<ImmutableNode>> results =
resolver.resolveKey(tx.getQueryRoot(), key,
tx.getCurrentData());
return initializeClearTransaction(tx, results);
@@ -388,9 +388,9 @@ public class InMemoryNodeModel implement
* @param resolver the {@code NodeKeyResolver}
*/
@Override
- public void clear(NodeKeyResolver<ImmutableNode> resolver)
+ public void clear(final NodeKeyResolver<ImmutableNode> resolver)
{
- ImmutableNode newRoot =
+ final ImmutableNode newRoot =
new ImmutableNode.Builder().name(getRootNode().getNodeName())
.create();
setRootNode(newRoot);
@@ -416,7 +416,7 @@ public class InMemoryNodeModel implement
* empty root node is set)
*/
@Override
- public void setRootNode(ImmutableNode newRoot)
+ public void setRootNode(final ImmutableNode newRoot)
{
structure.set(createTreeData(initialRootNode(newRoot), structure.get()));
}
@@ -435,8 +435,8 @@ public class InMemoryNodeModel implement
* @param resolver the {@code NodeKeyResolver}
* @throws IllegalArgumentException if the new root node is <b>null</b>
*/
- public void replaceRoot(ImmutableNode newRoot,
- NodeKeyResolver<ImmutableNode> resolver)
+ public void replaceRoot(final ImmutableNode newRoot,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
if (newRoot == null)
{
@@ -444,9 +444,9 @@ public class InMemoryNodeModel implement
"Replaced root node must not be null!");
}
- TreeData current = structure.get();
+ final TreeData current = structure.get();
// this step is needed to get a valid NodeHandler
- TreeData temp =
+ final TreeData temp =
createTreeDataForRootAndTracker(newRoot,
current.getNodeTracker());
structure.set(temp.updateNodeTracker(temp.getNodeTracker().update(
@@ -469,15 +469,15 @@ public class InMemoryNodeModel implement
*/
public void mergeRoot(final ImmutableNode node, final String rootName,
final Map<ImmutableNode, ?> references, final Object rootRef,
- NodeKeyResolver<ImmutableNode> resolver)
+ final NodeKeyResolver<ImmutableNode> resolver)
{
updateModel(new TransactionInitializer()
{
@Override
- public boolean initTransaction(ModelTransaction tx)
+ public boolean initTransaction(final ModelTransaction tx)
{
- TreeData current = tx.getCurrentData();
- String newRootName =
+ final TreeData current = tx.getCurrentData();
+ final String newRootName =
determineRootName(current.getRootNode(), node, rootName);
if (newRootName != null)
{
@@ -521,14 +521,14 @@ public class InMemoryNodeModel implement
* @throws ConfigurationRuntimeException if the selector does not select a
* single node
*/
- public void trackNode(NodeSelector selector,
- NodeKeyResolver<ImmutableNode> resolver)
+ public void trackNode(final NodeSelector selector,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
boolean done;
do
{
- TreeData current = structure.get();
- NodeTracker newTracker =
+ final TreeData current = structure.get();
+ final NodeTracker newTracker =
current.getNodeTracker().trackNode(current.getRootNode(),
selector, resolver, current);
done =
@@ -549,16 +549,16 @@ public class InMemoryNodeModel implement
* @return a collection with the {@code NodeSelector} objects for the new
* tracked nodes
*/
- public Collection<NodeSelector> selectAndTrackNodes(String key,
- NodeKeyResolver<ImmutableNode> resolver)
+ public Collection<NodeSelector> selectAndTrackNodes(final String key,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
- Mutable<Collection<NodeSelector>> refSelectors =
+ final Mutable<Collection<NodeSelector>> refSelectors =
new MutableObject<>();
boolean done;
do
{
- TreeData current = structure.get();
- List<ImmutableNode> nodes =
+ final TreeData current = structure.get();
+ final List<ImmutableNode> nodes =
resolver.resolveNodeKey(current.getRootNode(), key, current);
if (nodes.isEmpty())
{
@@ -586,21 +586,21 @@ public class InMemoryNodeModel implement
* @return a collection with the {@code NodeSelector} objects for the new
* tracked nodes
*/
- public Collection<NodeSelector> trackChildNodes(String key,
- NodeKeyResolver<ImmutableNode> resolver)
+ public Collection<NodeSelector> trackChildNodes(final String key,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
- Mutable<Collection<NodeSelector>> refSelectors =
+ final Mutable<Collection<NodeSelector>> refSelectors =
new MutableObject<>();
boolean done;
do
{
refSelectors.setValue(Collections.<NodeSelector> emptyList());
- TreeData current = structure.get();
- List<ImmutableNode> nodes =
+ final TreeData current = structure.get();
+ final List<ImmutableNode> nodes =
resolver.resolveNodeKey(current.getRootNode(), key, current);
if (nodes.size() == 1)
{
- ImmutableNode node = nodes.get(0);
+ final ImmutableNode node = nodes.get(0);
done =
node.getChildren().isEmpty()
|| structure.compareAndSet(
@@ -631,17 +631,17 @@ public class InMemoryNodeModel implement
* @throws ConfigurationRuntimeException if the passed in key does not
* select a single node
*/
- public NodeSelector trackChildNodeWithCreation(String key,
- String childName, NodeKeyResolver<ImmutableNode> resolver)
+ public NodeSelector trackChildNodeWithCreation(final String key,
+ final String childName, final NodeKeyResolver<ImmutableNode> resolver)
{
- MutableObject<NodeSelector> refSelector =
+ final MutableObject<NodeSelector> refSelector =
new MutableObject<>();
boolean done;
do
{
- TreeData current = structure.get();
- List<ImmutableNode> nodes =
+ final TreeData current = structure.get();
+ final List<ImmutableNode> nodes =
resolver.resolveNodeKey(current.getRootNode(), key, current);
if (nodes.size() != 1)
{
@@ -649,8 +649,8 @@ public class InMemoryNodeModel implement
"Key does not select a single node: " + key);
}
- ImmutableNode parent = nodes.get(0);
- TreeData newData =
+ final ImmutableNode parent = nodes.get(0);
+ final TreeData newData =
createDataWithTrackedChildNode(current, parent, childName,
resolver, refSelector);
@@ -670,7 +670,7 @@ public class InMemoryNodeModel implement
* @return the current {@code ImmutableNode} associated with this selector
* @throws ConfigurationRuntimeException if the selector is unknown
*/
- public ImmutableNode getTrackedNode(NodeSelector selector)
+ public ImmutableNode getTrackedNode(final NodeSelector selector)
{
return structure.get().getNodeTracker().getTrackedNode(selector);
}
@@ -688,7 +688,7 @@ public class InMemoryNodeModel implement
* @throws ConfigurationRuntimeException if the selector cannot be resolved
* @throws IllegalArgumentException if the replacement node is <b>null</b>
*/
- public void replaceTrackedNode(NodeSelector selector, ImmutableNode newNode)
+ public void replaceTrackedNode(final NodeSelector selector, final ImmutableNode newNode)
{
if (newNode == null)
{
@@ -699,7 +699,7 @@ public class InMemoryNodeModel implement
boolean done;
do
{
- TreeData currentData = structure.get();
+ final TreeData currentData = structure.get();
done =
replaceDetachedTrackedNode(currentData, selector, newNode)
|| replaceActiveTrackedNode(currentData, selector,
@@ -721,10 +721,10 @@ public class InMemoryNodeModel implement
* @throws ConfigurationRuntimeException if the selector is unknown
*/
public NodeHandler<ImmutableNode> getTrackedNodeHandler(
- NodeSelector selector)
+ final NodeSelector selector)
{
- TreeData currentData = structure.get();
- InMemoryNodeModel detachedNodeModel =
+ final TreeData currentData = structure.get();
+ final InMemoryNodeModel detachedNodeModel =
currentData.getNodeTracker().getDetachedNodeModel(selector);
return (detachedNodeModel != null) ? detachedNodeModel.getNodeHandler()
: new TrackedNodeHandler(currentData.getNodeTracker()
@@ -747,7 +747,7 @@ public class InMemoryNodeModel implement
* @return a flag whether this tracked node is in detached state
* @throws ConfigurationRuntimeException if the selector is unknown
*/
- public boolean isTrackedNodeDetached(NodeSelector selector)
+ public boolean isTrackedNodeDetached(final NodeSelector selector)
{
return structure.get().getNodeTracker().isTrackedNodeDetached(selector);
}
@@ -763,13 +763,13 @@ public class InMemoryNodeModel implement
* @throws ConfigurationRuntimeException if the specified node is not
* tracked
*/
- public void untrackNode(NodeSelector selector)
+ public void untrackNode(final NodeSelector selector)
{
boolean done;
do
{
- TreeData current = structure.get();
- NodeTracker newTracker =
+ final TreeData current = structure.get();
+ final NodeTracker newTracker =
current.getNodeTracker().untrackNode(selector);
done =
structure.compareAndSet(current,
@@ -810,16 +810,16 @@ public class InMemoryNodeModel implement
* @param root the root node of the current tree
*/
static void updateParentMapping(final Map<ImmutableNode, ImmutableNode> parents,
- ImmutableNode root)
+ final ImmutableNode root)
{
NodeTreeWalker.INSTANCE.walkBFS(root,
new ConfigurationNodeVisitorAdapter<ImmutableNode>()
{
@Override
- public void visitBeforeChildren(ImmutableNode node,
- NodeHandler<ImmutableNode> handler)
+ public void visitBeforeChildren(final ImmutableNode node,
+ final NodeHandler<ImmutableNode> handler)
{
- for (ImmutableNode c : node.getChildren())
+ for (final ImmutableNode c : node.getChildren())
{
parents.put(c, node);
}
@@ -834,7 +834,7 @@ public class InMemoryNodeModel implement
* @param node the node in question
* @return <b>true</b> if the node is defined, <b>false</b> otherwise
*/
- static boolean checkIfNodeDefined(ImmutableNode node)
+ static boolean checkIfNodeDefined(final ImmutableNode node)
{
return node.getValue() != null || !node.getChildren().isEmpty()
|| !node.getAttributes().isEmpty();
@@ -848,10 +848,10 @@ public class InMemoryNodeModel implement
* @param values the collection with node values
* @param resolver the {@code NodeKeyResolver}
*/
- private void initializeAddTransaction(ModelTransaction tx, String key,
- Iterable<?> values, NodeKeyResolver<ImmutableNode> resolver)
+ private void initializeAddTransaction(final ModelTransaction tx, final String key,
+ final Iterable<?> values, final NodeKeyResolver<ImmutableNode> resolver)
{
- NodeAddData<ImmutableNode> addData =
+ final NodeAddData<ImmutableNode> addData =
resolver.resolveAddKey(tx.getQueryRoot(), key,
tx.getCurrentData());
if (addData.isAttribute())
@@ -871,9 +871,9 @@ public class InMemoryNodeModel implement
* @param current the current {@code TreeData} object (may be <b>null</b>)
* @return the {@code TreeData} describing the current tree
*/
- private TreeData createTreeData(ImmutableNode root, TreeData current)
+ private TreeData createTreeData(final ImmutableNode root, final TreeData current)
{
- NodeTracker newTracker =
+ final NodeTracker newTracker =
(current != null) ? current.getNodeTracker()
.detachAllTrackedNodes() : new NodeTracker();
return createTreeDataForRootAndTracker(root, newTracker);
@@ -887,8 +887,8 @@ public class InMemoryNodeModel implement
* @param newTracker the new {@code NodeTracker}
* @return the new {@code TreeData} object
*/
- private TreeData createTreeDataForRootAndTracker(ImmutableNode root,
- NodeTracker newTracker)
+ private TreeData createTreeDataForRootAndTracker(final ImmutableNode root,
+ final NodeTracker newTracker)
{
return new TreeData(root, createParentMapping(root),
Collections.<ImmutableNode, ImmutableNode> emptyMap(),
@@ -902,10 +902,10 @@ public class InMemoryNodeModel implement
* @param addData the {@code NodeAddData}
* @param values the collection with node values
*/
- private static void addNodeProperty(ModelTransaction tx,
- NodeAddData<ImmutableNode> addData, Iterable<?> values)
+ private static void addNodeProperty(final ModelTransaction tx,
+ final NodeAddData<ImmutableNode> addData, final Iterable<?> values)
{
- Collection<ImmutableNode> newNodes =
+ final Collection<ImmutableNode> newNodes =
createNodesToAdd(addData.getNewNodeName(), values);
addNodesByAddData(tx, addData, newNodes);
}
@@ -920,9 +920,9 @@ public class InMemoryNodeModel implement
* @param addData the {@code NodeAddData}
* @param newNodes the collection of new child nodes
*/
- private static void addNodesByAddData(ModelTransaction tx,
- NodeAddData<ImmutableNode> addData,
- Collection<ImmutableNode> newNodes)
+ private static void addNodesByAddData(final ModelTransaction tx,
+ final NodeAddData<ImmutableNode> addData,
+ final Collection<ImmutableNode> newNodes)
{
if (addData.getPathNodes().isEmpty())
{
@@ -930,7 +930,7 @@ public class InMemoryNodeModel implement
}
else
{
- ImmutableNode newChild = createNodeToAddWithPath(addData, newNodes);
+ final ImmutableNode newChild = createNodeToAddWithPath(addData, newNodes);
tx.addAddNodeOperation(addData.getParent(), newChild);
}
}
@@ -943,8 +943,8 @@ public class InMemoryNodeModel implement
* @param addData the {@code NodeAddData}
* @param values the collection with node values
*/
- private static void addAttributeProperty(ModelTransaction tx,
- NodeAddData<ImmutableNode> addData, Iterable<?> values)
+ private static void addAttributeProperty(final ModelTransaction tx,
+ final NodeAddData<ImmutableNode> addData, final Iterable<?> values)
{
if (addData.getPathNodes().isEmpty())
{
@@ -953,13 +953,13 @@ public class InMemoryNodeModel implement
}
else
{
- int pathNodeCount = addData.getPathNodes().size();
- ImmutableNode childWithAttribute =
+ final int pathNodeCount = addData.getPathNodes().size();
+ final ImmutableNode childWithAttribute =
new ImmutableNode.Builder()
.name(addData.getPathNodes().get(pathNodeCount - 1))
.addAttribute(addData.getNewNodeName(),
values.iterator().next()).create();
- ImmutableNode newChild =
+ final ImmutableNode newChild =
(pathNodeCount > 1) ? createNodeOnPath(addData
.getPathNodes().subList(0, pathNodeCount - 1)
.iterator(),
@@ -978,10 +978,10 @@ public class InMemoryNodeModel implement
* @return the newly created collection
*/
private static Collection<ImmutableNode> createNodesToAdd(
- String newNodeName, Iterable<?> values)
+ final String newNodeName, final Iterable<?> values)
{
- Collection<ImmutableNode> nodes = new LinkedList<>();
- for (Object value : values)
+ final Collection<ImmutableNode> nodes = new LinkedList<>();
+ for (final Object value : values)
{
nodes.add(new ImmutableNode.Builder().name(newNodeName)
.value(value).create());
@@ -998,8 +998,8 @@ public class InMemoryNodeModel implement
* @return the parent node of the newly created hierarchy
*/
private static ImmutableNode createNodeToAddWithPath(
- NodeAddData<ImmutableNode> addData,
- Collection<ImmutableNode> newNodes)
+ final NodeAddData<ImmutableNode> addData,
+ final Collection<ImmutableNode> newNodes)
{
return createNodeOnPath(addData.getPathNodes().iterator(), newNodes);
}
@@ -1013,10 +1013,10 @@ public class InMemoryNodeModel implement
* @param newNodes the collection of new child nodes
* @return the newly created path node
*/
- private static ImmutableNode createNodeOnPath(Iterator<String> it,
- Collection<ImmutableNode> newNodes)
+ private static ImmutableNode createNodeOnPath(final Iterator<String> it,
+ final Collection<ImmutableNode> newNodes)
{
- String nodeName = it.next();
+ final String nodeName = it.next();
ImmutableNode.Builder builder;
if (it.hasNext())
{
@@ -1040,10 +1040,10 @@ public class InMemoryNodeModel implement
* cleared
* @return a flag whether there are elements to be cleared
*/
- private static boolean initializeClearTransaction(ModelTransaction tx,
- Collection<QueryResult<ImmutableNode>> results)
+ private static boolean initializeClearTransaction(final ModelTransaction tx,
+ final Collection<QueryResult<ImmutableNode>> results)
{
- for (QueryResult<ImmutableNode> result : results)
+ for (final QueryResult<ImmutableNode> result : results)
{
if (result.isAttributeResult())
{
@@ -1067,10 +1067,10 @@ public class InMemoryNodeModel implement
* @param changedValues the map defining the elements to be changed
* @return a flag whether there are elements to be updated
*/
- private static boolean initializeUpdateTransaction(ModelTransaction tx,
- Map<QueryResult<ImmutableNode>, Object> changedValues)
+ private static boolean initializeUpdateTransaction(final ModelTransaction tx,
+ final Map<QueryResult<ImmutableNode>, Object> changedValues)
{
- for (Map.Entry<QueryResult<ImmutableNode>, Object> e : changedValues
+ for (final Map.Entry<QueryResult<ImmutableNode>, Object> e : changedValues
.entrySet())
{
if (e.getKey().isAttributeResult())
@@ -1095,7 +1095,7 @@ public class InMemoryNodeModel implement
* @param providedRoot the passed in root node
* @return the root node to be used
*/
- private static ImmutableNode initialRootNode(ImmutableNode providedRoot)
+ private static ImmutableNode initialRootNode(final ImmutableNode providedRoot)
{
return (providedRoot != null) ? providedRoot
: new ImmutableNode.Builder().create();
@@ -1112,8 +1112,8 @@ public class InMemoryNodeModel implement
* @param rootName the name of the resulting node
* @return the new name of the root node
*/
- private static String determineRootName(ImmutableNode rootNode,
- ImmutableNode node, String rootName)
+ private static String determineRootName(final ImmutableNode rootNode,
+ final ImmutableNode node, final String rootName)
{
if (rootName != null)
{
@@ -1136,9 +1136,9 @@ public class InMemoryNodeModel implement
* @return the parent node mapping
*/
private Map<ImmutableNode, ImmutableNode> createParentMapping(
- ImmutableNode root)
+ final ImmutableNode root)
{
- Map<ImmutableNode, ImmutableNode> parents =
+ final Map<ImmutableNode, ImmutableNode> parents =
new HashMap<>();
updateParentMapping(parents, root);
return parents;
@@ -1155,14 +1155,14 @@ public class InMemoryNodeModel implement
* of the transaction
* @param resolver the {@code NodeKeyResolver}
*/
- private void updateModel(TransactionInitializer txInit,
- NodeSelector selector, NodeKeyResolver<ImmutableNode> resolver)
+ private void updateModel(final TransactionInitializer txInit,
+ final NodeSelector selector, final NodeKeyResolver<ImmutableNode> resolver)
{
boolean done;
do
{
- TreeData currentData = getTreeData();
+ final TreeData currentData = getTreeData();
done =
executeTransactionOnDetachedTrackedNode(txInit, selector,
currentData, resolver)
@@ -1183,11 +1183,11 @@ public class InMemoryNodeModel implement
* @return a flag whether the operation has been completed successfully
*/
private boolean executeTransactionOnCurrentStructure(
- TransactionInitializer txInit, NodeSelector selector,
- TreeData currentData, NodeKeyResolver<ImmutableNode> resolver)
+ final TransactionInitializer txInit, final NodeSelector selector,
+ final TreeData currentData, final NodeKeyResolver<ImmutableNode> resolver)
{
boolean done;
- ModelTransaction tx =
+ final ModelTransaction tx =
new ModelTransaction(currentData, selector, resolver);
if (!txInit.initTransaction(tx))
{
@@ -1195,7 +1195,7 @@ public class InMemoryNodeModel implement
}
else
{
- TreeData newData = tx.execute();
+ final TreeData newData = tx.execute();
done = structure.compareAndSet(tx.getCurrentData(), newData);
}
return done;
@@ -1216,12 +1216,12 @@ public class InMemoryNodeModel implement
* @throws ConfigurationRuntimeException if the selector cannot be resolved
*/
private boolean executeTransactionOnDetachedTrackedNode(
- TransactionInitializer txInit, NodeSelector selector,
- TreeData currentData, NodeKeyResolver<ImmutableNode> resolver)
+ final TransactionInitializer txInit, final NodeSelector selector,
+ final TreeData currentData, final NodeKeyResolver<ImmutableNode> resolver)
{
if (selector != null)
{
- InMemoryNodeModel detachedNodeModel =
+ final InMemoryNodeModel detachedNodeModel =
currentData.getNodeTracker().getDetachedNodeModel(selector);
if (detachedNodeModel != null)
{
@@ -1241,10 +1241,10 @@ public class InMemoryNodeModel implement
* @param newNode the node replacing the tracked node
* @return a flag whether the operation was successful
*/
- private boolean replaceDetachedTrackedNode(TreeData currentData,
- NodeSelector selector, ImmutableNode newNode)
+ private boolean replaceDetachedTrackedNode(final TreeData currentData,
+ final NodeSelector selector, final ImmutableNode newNode)
{
- InMemoryNodeModel detachedNodeModel =
+ final InMemoryNodeModel detachedNodeModel =
currentData.getNodeTracker().getDetachedNodeModel(selector);
if (detachedNodeModel != null)
{
@@ -1263,10 +1263,10 @@ public class InMemoryNodeModel implement
* @param newNode the node replacing the tracked node
* @return a flag whether the operation was successful
*/
- private boolean replaceActiveTrackedNode(TreeData currentData,
- NodeSelector selector, ImmutableNode newNode)
+ private boolean replaceActiveTrackedNode(final TreeData currentData,
+ final NodeSelector selector, final ImmutableNode newNode)
{
- NodeTracker newTracker =
+ final NodeTracker newTracker =
currentData.getNodeTracker().replaceAndDetachTrackedNode(
selector, newNode);
return structure.compareAndSet(currentData,
@@ -1284,20 +1284,20 @@ public class InMemoryNodeModel implement
* @return the updated {@code TreeData} object
*/
private static TreeData createSelectorsForTrackedNodes(
- Mutable<Collection<NodeSelector>> refSelectors,
- List<ImmutableNode> nodes, TreeData current,
- NodeKeyResolver<ImmutableNode> resolver)
+ final Mutable<Collection<NodeSelector>> refSelectors,
+ final List<ImmutableNode> nodes, final TreeData current,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
- List<NodeSelector> selectors =
+ final List<NodeSelector> selectors =
new ArrayList<>(nodes.size());
- Map<ImmutableNode, String> cache = new HashMap<>();
- for (ImmutableNode node : nodes)
+ final Map<ImmutableNode, String> cache = new HashMap<>();
+ for (final ImmutableNode node : nodes)
{
selectors.add(new NodeSelector(resolver.nodeKey(node, cache,
current)));
}
refSelectors.setValue(selectors);
- NodeTracker newTracker =
+ final NodeTracker newTracker =
current.getNodeTracker().trackNodes(selectors, nodes);
return current.updateNodeTracker(newTracker);
}
@@ -1313,15 +1313,15 @@ public class InMemoryNodeModel implement
* returned
* @return the new {@code TreeData} instance
*/
- private static TreeData updateDataWithNewTrackedNode(TreeData current,
- ImmutableNode node, NodeKeyResolver<ImmutableNode> resolver,
- MutableObject<NodeSelector> refSelector)
+ private static TreeData updateDataWithNewTrackedNode(final TreeData current,
+ final ImmutableNode node, final NodeKeyResolver<ImmutableNode> resolver,
+ final MutableObject<NodeSelector> refSelector)
{
- NodeSelector selector =
+ final NodeSelector selector =
new NodeSelector(resolver.nodeKey(node,
new HashMap<ImmutableNode, String>(), current));
refSelector.setValue(selector);
- NodeTracker newTracker =
+ final NodeTracker newTracker =
current.getNodeTracker().trackNodes(
Collections.singleton(selector),
Collections.singleton(node));
@@ -1341,13 +1341,13 @@ public class InMemoryNodeModel implement
* returned
* @return the new {@code TreeData} instance
*/
- private static TreeData createDataWithTrackedChildNode(TreeData current,
- ImmutableNode parent, String childName,
- NodeKeyResolver<ImmutableNode> resolver,
- MutableObject<NodeSelector> refSelector)
+ private static TreeData createDataWithTrackedChildNode(final TreeData current,
+ final ImmutableNode parent, final String childName,
+ final NodeKeyResolver<ImmutableNode> resolver,
+ final MutableObject<NodeSelector> refSelector)
{
TreeData newData;
- List<ImmutableNode> namedChildren =
+ final List<ImmutableNode> namedChildren =
current.getChildren(parent, childName);
if (!namedChildren.isEmpty())
{
@@ -1357,9 +1357,9 @@ public class InMemoryNodeModel implement
}
else
{
- ImmutableNode child =
+ final ImmutableNode child =
new ImmutableNode.Builder().name(childName).create();
- ModelTransaction tx = new ModelTransaction(current, null, resolver);
+ final ModelTransaction tx = new ModelTransaction(current, null, resolver);
tx.addAddNodeOperation(parent, child);
newData =
updateDataWithNewTrackedNode(tx.execute(), child, resolver,
@@ -1374,7 +1374,7 @@ public class InMemoryNodeModel implement
* @param values the collection with node values
* @return <b>true</b> if values are provided, <b>false</b> otherwise
*/
- private static boolean valuesNotEmpty(Iterable<?> values)
+ private static boolean valuesNotEmpty(final Iterable<?> values)
{
return values.iterator().hasNext();
}
@@ -1387,7 +1387,7 @@ public class InMemoryNodeModel implement
* @param key the invalid key causing this exception
* @return the exception
*/
- private static RuntimeException attributeKeyException(String key)
+ private static RuntimeException attributeKeyException(final String key)
{
return new IllegalArgumentException(
"New nodes cannot be added to an attribute key: " + key);
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/MergeCombiner.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/MergeCombiner.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/MergeCombiner.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/MergeCombiner.java Thu Sep 27 22:24:23 2018
@@ -52,18 +52,18 @@ public class MergeCombiner extends NodeC
*/
@Override
- public ImmutableNode combine(ImmutableNode node1, ImmutableNode node2)
+ public ImmutableNode combine(final ImmutableNode node1, final ImmutableNode node2)
{
- ImmutableNode.Builder result = new ImmutableNode.Builder();
+ final ImmutableNode.Builder result = new ImmutableNode.Builder();
result.name(node1.getNodeName());
result.value(node1.getValue());
addAttributes(result, node1, node2);
// Check if nodes can be combined
- List<ImmutableNode> children2 = new LinkedList<>(node2.getChildren());
- for (ImmutableNode child1 : node1.getChildren())
+ final List<ImmutableNode> children2 = new LinkedList<>(node2.getChildren());
+ for (final ImmutableNode child1 : node1.getChildren())
{
- ImmutableNode child2 = canCombine(node2, child1, children2);
+ final ImmutableNode child2 = canCombine(node2, child1, children2);
if (child2 != null)
{
result.addChild(combine(child1, child2));
@@ -76,7 +76,7 @@ public class MergeCombiner extends NodeC
}
// Add remaining children of node 2
- for (ImmutableNode c : children2)
+ for (final ImmutableNode c : children2)
{
result.addChild(c);
}
@@ -93,12 +93,12 @@ public class MergeCombiner extends NodeC
* @param node1 the first node
* @param node2 the second node
*/
- protected void addAttributes(ImmutableNode.Builder result, ImmutableNode node1,
- ImmutableNode node2)
+ protected void addAttributes(final ImmutableNode.Builder result, final ImmutableNode node1,
+ final ImmutableNode node2)
{
- Map<String, Object> attributes = new HashMap<>();
+ final Map<String, Object> attributes = new HashMap<>();
attributes.putAll(node1.getAttributes());
- for (Map.Entry<String, Object> e : node2.getAttributes().entrySet())
+ for (final Map.Entry<String, Object> e : node2.getAttributes().entrySet())
{
if (!attributes.containsKey(e.getKey()))
{
@@ -118,15 +118,15 @@ public class MergeCombiner extends NodeC
* @param children2 the children of the 2nd node
* @return a child of the second node, with which a combination is possible
*/
- protected ImmutableNode canCombine(ImmutableNode node2,
- ImmutableNode child, List<ImmutableNode> children2)
+ protected ImmutableNode canCombine(final ImmutableNode node2,
+ final ImmutableNode child, final List<ImmutableNode> children2)
{
- Map<String, Object> attrs1 = child.getAttributes();
- List<ImmutableNode> nodes = new ArrayList<>();
+ final Map<String, Object> attrs1 = child.getAttributes();
+ final List<ImmutableNode> nodes = new ArrayList<>();
- List<ImmutableNode> children =
+ final List<ImmutableNode> children =
HANDLER.getChildren(node2, child.getNodeName());
- for (ImmutableNode node : children)
+ for (final ImmutableNode node : children)
{
if (matchAttributes(attrs1, node))
{
@@ -140,7 +140,7 @@ public class MergeCombiner extends NodeC
}
if (nodes.size() > 1 && !isListNode(child))
{
- for (ImmutableNode node : nodes)
+ for (final ImmutableNode node : nodes)
{
children2.remove(node);
}
@@ -157,11 +157,11 @@ public class MergeCombiner extends NodeC
* @return a flag whether these nodes can be combined regarding their
* attributes
*/
- private static boolean matchAttributes(Map<String, Object> attrs1,
- ImmutableNode node)
+ private static boolean matchAttributes(final Map<String, Object> attrs1,
+ final ImmutableNode node)
{
- Map<String, Object> attrs2 = node.getAttributes();
- for (Map.Entry<String, Object> e : attrs1.entrySet())
+ final Map<String, Object> attrs2 = node.getAttributes();
+ for (final Map.Entry<String, Object> e : attrs1.entrySet())
{
if (attrs2.containsKey(e.getKey())
&& !Objects
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/ModelTransaction.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/ModelTransaction.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/ModelTransaction.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/ModelTransaction.java Thu Sep 27 22:24:23 2018
@@ -134,8 +134,8 @@ class ModelTransaction
* on tracked nodes
* @param resolver the {@code NodeKeyResolver}
*/
- public ModelTransaction(TreeData treeData, NodeSelector selector,
- NodeKeyResolver<ImmutableNode> resolver)
+ public ModelTransaction(final TreeData treeData, final NodeSelector selector,
+ final NodeKeyResolver<ImmutableNode> resolver)
{
currentData = treeData;
this.resolver = resolver;
@@ -180,10 +180,10 @@ class ModelTransaction
* @param parent the parent node
* @param newNodes the collection of new child nodes
*/
- public void addAddNodesOperation(ImmutableNode parent,
- Collection<? extends ImmutableNode> newNodes)
+ public void addAddNodesOperation(final ImmutableNode parent,
+ final Collection<? extends ImmutableNode> newNodes)
{
- ChildrenUpdateOperation op = new ChildrenUpdateOperation();
+ final ChildrenUpdateOperation op = new ChildrenUpdateOperation();
op.addNewNodes(newNodes);
fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op);
}
@@ -194,9 +194,9 @@ class ModelTransaction
* @param parent the parent node
* @param newChild the new child to be added
*/
- public void addAddNodeOperation(ImmutableNode parent, ImmutableNode newChild)
+ public void addAddNodeOperation(final ImmutableNode parent, final ImmutableNode newChild)
{
- ChildrenUpdateOperation op = new ChildrenUpdateOperation();
+ final ChildrenUpdateOperation op = new ChildrenUpdateOperation();
op.addNewNode(newChild);
fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op);
}
@@ -208,8 +208,8 @@ class ModelTransaction
* @param name the name of the attribute
* @param value the value of the attribute
*/
- public void addAttributeOperation(ImmutableNode target, String name,
- Object value)
+ public void addAttributeOperation(final ImmutableNode target, final String name,
+ final Object value)
{
fetchOperations(target, LEVEL_UNKNOWN).addOperation(
new AddAttributeOperation(name, value));
@@ -221,8 +221,8 @@ class ModelTransaction
* @param target the target node
* @param attributes the map with attributes to be set
*/
- public void addAttributesOperation(ImmutableNode target,
- Map<String, Object> attributes)
+ public void addAttributesOperation(final ImmutableNode target,
+ final Map<String, Object> attributes)
{
fetchOperations(target, LEVEL_UNKNOWN).addOperation(
new AddAttributesOperation(attributes));
@@ -234,9 +234,9 @@ class ModelTransaction
* @param parent the parent node
* @param node the child node to be removed
*/
- public void addRemoveNodeOperation(ImmutableNode parent, ImmutableNode node)
+ public void addRemoveNodeOperation(final ImmutableNode parent, final ImmutableNode node)
{
- ChildrenUpdateOperation op = new ChildrenUpdateOperation();
+ final ChildrenUpdateOperation op = new ChildrenUpdateOperation();
op.addNodeToRemove(node);
fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op);
}
@@ -247,7 +247,7 @@ class ModelTransaction
* @param target the target node
* @param name the name of the attribute
*/
- public void addRemoveAttributeOperation(ImmutableNode target, String name)
+ public void addRemoveAttributeOperation(final ImmutableNode target, final String name)
{
fetchOperations(target, LEVEL_UNKNOWN).addOperation(
new RemoveAttributeOperation(name));
@@ -258,7 +258,7 @@ class ModelTransaction
*
* @param target the target node
*/
- public void addClearNodeValueOperation(ImmutableNode target)
+ public void addClearNodeValueOperation(final ImmutableNode target)
{
addChangeNodeValueOperation(target, null);
}
@@ -269,8 +269,8 @@ class ModelTransaction
* @param target the target node
* @param newValue the new value for this node
*/
- public void addChangeNodeValueOperation(ImmutableNode target,
- Object newValue)
+ public void addChangeNodeValueOperation(final ImmutableNode target,
+ final Object newValue)
{
fetchOperations(target, LEVEL_UNKNOWN).addOperation(
new ChangeNodeValueOperation(newValue));
@@ -282,7 +282,7 @@ class ModelTransaction
* @param target the target node
* @param newName the new name for this node
*/
- public void addChangeNodeNameOperation(ImmutableNode target, String newName)
+ public void addChangeNodeNameOperation(final ImmutableNode target, final String newName)
{
fetchOperations(target, LEVEL_UNKNOWN).addOperation(
new ChangeNodeNameOperation(newName));
@@ -294,7 +294,7 @@ class ModelTransaction
*
* @param refs the map with new reference objects
*/
- public void addNewReferences(Map<ImmutableNode, ?> refs)
+ public void addNewReferences(final Map<ImmutableNode, ?> refs)
{
fetchReferenceMap().putAll(refs);
}
@@ -305,7 +305,7 @@ class ModelTransaction
* @param node the affected node
* @param ref the reference object for this node
*/
- public void addNewReference(ImmutableNode node, Object ref)
+ public void addNewReference(final ImmutableNode node, final Object ref)
{
fetchReferenceMap().put(node, ref);
}
@@ -342,7 +342,7 @@ class ModelTransaction
* @param node the node in question
* @return the parent of this node
*/
- ImmutableNode getParent(ImmutableNode node)
+ ImmutableNode getParent(final ImmutableNode node)
{
return getCurrentData().getParent(node);
}
@@ -356,9 +356,9 @@ class ModelTransaction
* @param level the level of the target node (may be undefined)
* @return the {@code Operations} object for this node
*/
- Operations fetchOperations(ImmutableNode target, int level)
+ Operations fetchOperations(final ImmutableNode target, final int level)
{
- Integer nodeLevel =
+ final Integer nodeLevel =
Integer.valueOf((level == LEVEL_UNKNOWN) ? level(target)
: level);
Map<ImmutableNode, Operations> levelOperations =
@@ -386,7 +386,7 @@ class ModelTransaction
* @param selector an optional {@code NodeSelector} defining the target root
* @return the query root node for this transaction
*/
- private ImmutableNode initQueryRoot(TreeData treeData, NodeSelector selector)
+ private ImmutableNode initQueryRoot(final TreeData treeData, final NodeSelector selector)
{
return (selector == null) ? treeData.getRootNode() : treeData
.getNodeTracker().getTrackedNode(selector);
@@ -400,7 +400,7 @@ class ModelTransaction
* @param node the node in question
* @return the level of this node
*/
- private int level(ImmutableNode node)
+ private int level(final ImmutableNode node)
{
ImmutableNode current = getCurrentData().getParent(node);
int level = 0;
@@ -419,9 +419,9 @@ class ModelTransaction
{
while (!operations.isEmpty())
{
- Integer level = operations.lastKey(); // start down in hierarchy
- Map<ImmutableNode, Operations> levelOps = operations.remove(level);
- for (Map.Entry<ImmutableNode, Operations> e : levelOps.entrySet())
+ final Integer level = operations.lastKey(); // start down in hierarchy
+ final Map<ImmutableNode, Operations> levelOps = operations.remove(level);
+ for (final Map.Entry<ImmutableNode, Operations> e : levelOps.entrySet())
{
e.getValue().apply(e.getKey(), level);
}
@@ -465,7 +465,7 @@ class ModelTransaction
*/
private void updateParentMappingForAddedNodes()
{
- for (ImmutableNode node : addedNodes)
+ for (final ImmutableNode node : addedNodes)
{
InMemoryNodeModel.updateParentMapping(parentMapping, node);
}
@@ -477,7 +477,7 @@ class ModelTransaction
*/
private void updateParentMappingForRemovedNodes()
{
- for (ImmutableNode node : removedNodes)
+ for (final ImmutableNode node : removedNodes)
{
removeNodesFromParentAndReplacementMapping(node);
}
@@ -489,14 +489,14 @@ class ModelTransaction
*
* @param root the root of the subtree to be removed
*/
- private void removeNodesFromParentAndReplacementMapping(ImmutableNode root)
+ private void removeNodesFromParentAndReplacementMapping(final ImmutableNode root)
{
NodeTreeWalker.INSTANCE.walkBFS(root,
new ConfigurationNodeVisitorAdapter<ImmutableNode>()
{
@Override
- public void visitBeforeChildren(ImmutableNode node,
- NodeHandler<ImmutableNode> handler)
+ public void visitBeforeChildren(final ImmutableNode node,
+ final NodeHandler<ImmutableNode> handler)
{
allRemovedNodes.add(node);
parentMapping.remove(node);
@@ -511,7 +511,7 @@ class ModelTransaction
*
* @param node the node to be removed
*/
- private void removeNodeFromReplacementMapping(ImmutableNode node)
+ private void removeNodeFromReplacementMapping(final ImmutableNode node)
{
ImmutableNode replacement = node;
do
@@ -558,15 +558,15 @@ class ModelTransaction
* @param <E> the type of the elements involved
* @return the resulting collection
*/
- private static <E> Collection<E> concatenate(Collection<E> col1,
- Collection<? extends E> col2)
+ private static <E> Collection<E> concatenate(final Collection<E> col1,
+ final Collection<? extends E> col2)
{
if (col2 == null)
{
return col1;
}
- Collection<E> result =
+ final Collection<E> result =
(col1 != null) ? col1 : new ArrayList<>(col2.size());
result.addAll(col2);
return result;
@@ -580,14 +580,14 @@ class ModelTransaction
* @param <E> the type of the elements involved
* @return the resulting set
*/
- private static <E> Set<E> concatenate(Set<E> set1, Set<? extends E> set2)
+ private static <E> Set<E> concatenate(final Set<E> set1, final Set<? extends E> set2)
{
if (set2 == null)
{
return set1;
}
- Set<E> result = (set1 != null) ? set1 : new HashSet<>();
+ final Set<E> result = (set1 != null) ? set1 : new HashSet<>();
result.addAll(set2);
return result;
}
@@ -601,15 +601,15 @@ class ModelTransaction
* @param <V> the type of the values
* @return the resulting map
*/
- private static <K, V> Map<K, V> concatenate(Map<K, V> map1,
- Map<? extends K, ? extends V> map2)
+ private static <K, V> Map<K, V> concatenate(final Map<K, V> map1,
+ final Map<? extends K, ? extends V> map2)
{
if (map2 == null)
{
return map1;
}
- Map<K, V> result = (map1 != null) ? map1 : new HashMap<>();
+ final Map<K, V> result = (map1 != null) ? map1 : new HashMap<>();
result.putAll(map2);
return result;
}
@@ -623,9 +623,9 @@ class ModelTransaction
* @param <E> the type of elements involved
* @return the resulting collection
*/
- private static <E> Collection<E> append(Collection<E> col, E node)
+ private static <E> Collection<E> append(final Collection<E> col, final E node)
{
- Collection<E> result = (col != null) ? col : new LinkedList<>();
+ final Collection<E> result = (col != null) ? col : new LinkedList<>();
result.add(node);
return result;
}
@@ -639,9 +639,9 @@ class ModelTransaction
* @param <E> the type of the elements involved
* @return the resulting set
*/
- private static <E> Set<E> append(Set<E> col, E elem)
+ private static <E> Set<E> append(final Set<E> col, final E elem)
{
- Set<E> result = (col != null) ? col : new HashSet<>();
+ final Set<E> result = (col != null) ? col : new HashSet<>();
result.add(elem);
return result;
}
@@ -657,9 +657,9 @@ class ModelTransaction
* @param <V> the type of the value
* @return the resulting map
*/
- private static <K, V> Map<K, V> append(Map<K, V> map, K key, V value)
+ private static <K, V> Map<K, V> append(final Map<K, V> map, final K key, final V value)
{
- Map<K, V> result = (map != null) ? map : new HashMap<>();
+ final Map<K, V> result = (map != null) ? map : new HashMap<>();
result.put(key, value);
return result;
}
@@ -710,7 +710,7 @@ class ModelTransaction
*
* @param op the operation to be combined
*/
- public void combine(ChildrenUpdateOperation op)
+ public void combine(final ChildrenUpdateOperation op)
{
newNodes = concatenate(newNodes, op.newNodes);
nodesToReplace = concatenate(nodesToReplace, op.nodesToReplace);
@@ -722,7 +722,7 @@ class ModelTransaction
*
* @param node the new node to be added
*/
- public void addNewNode(ImmutableNode node)
+ public void addNewNode(final ImmutableNode node)
{
newNodes = append(newNodes, node);
}
@@ -733,7 +733,7 @@ class ModelTransaction
*
* @param nodes the collection with new nodes
*/
- public void addNewNodes(Collection<? extends ImmutableNode> nodes)
+ public void addNewNodes(final Collection<? extends ImmutableNode> nodes)
{
newNodes = concatenate(newNodes, nodes);
}
@@ -745,8 +745,8 @@ class ModelTransaction
* @param org the original node
* @param replacement the replacement node
*/
- public void addNodeToReplace(ImmutableNode org,
- ImmutableNode replacement)
+ public void addNodeToReplace(final ImmutableNode org,
+ final ImmutableNode replacement)
{
nodesToReplace = append(nodesToReplace, org, replacement);
}
@@ -757,7 +757,7 @@ class ModelTransaction
*
* @param node the child node to be removed
*/
- public void addNodeToRemove(ImmutableNode node)
+ public void addNodeToRemove(final ImmutableNode node)
{
nodesToRemove = append(nodesToRemove, node);
}
@@ -769,17 +769,17 @@ class ModelTransaction
* removed.
*/
@Override
- protected ImmutableNode apply(ImmutableNode target,
- Operations operations)
+ protected ImmutableNode apply(final ImmutableNode target,
+ final Operations operations)
{
- Map<ImmutableNode, ImmutableNode> replacements =
+ final Map<ImmutableNode, ImmutableNode> replacements =
fetchReplacementMap();
- Set<ImmutableNode> removals = fetchRemovalSet();
- List<ImmutableNode> resultNodes = new LinkedList<>();
+ final Set<ImmutableNode> removals = fetchRemovalSet();
+ final List<ImmutableNode> resultNodes = new LinkedList<>();
- for (ImmutableNode nd : target.getChildren())
+ for (final ImmutableNode nd : target.getChildren())
{
- ImmutableNode repl = replacements.get(nd);
+ final ImmutableNode repl = replacements.get(nd);
if (repl != null)
{
resultNodes.add(repl);
@@ -845,15 +845,15 @@ class ModelTransaction
* @param name the name of the attribute
* @param value the value of the attribute
*/
- public AddAttributeOperation(String name, Object value)
+ public AddAttributeOperation(final String name, final Object value)
{
attributeName = name;
attributeValue = value;
}
@Override
- protected ImmutableNode apply(ImmutableNode target,
- Operations operations)
+ protected ImmutableNode apply(final ImmutableNode target,
+ final Operations operations)
{
return target.setAttribute(attributeName, attributeValue);
}
@@ -873,14 +873,14 @@ class ModelTransaction
*
* @param attrs the map with attributes
*/
- public AddAttributesOperation(Map<String, Object> attrs)
+ public AddAttributesOperation(final Map<String, Object> attrs)
{
attributes = attrs;
}
@Override
- protected ImmutableNode apply(ImmutableNode target,
- Operations operations)
+ protected ImmutableNode apply(final ImmutableNode target,
+ final Operations operations)
{
return target.setAttributes(attributes);
}
@@ -900,14 +900,14 @@ class ModelTransaction
*
* @param name the name of the attribute
*/
- public RemoveAttributeOperation(String name)
+ public RemoveAttributeOperation(final String name)
{
attributeName = name;
}
@Override
- protected ImmutableNode apply(ImmutableNode target,
- Operations operations)
+ protected ImmutableNode apply(final ImmutableNode target,
+ final Operations operations)
{
return target.removeAttribute(attributeName);
}
@@ -927,14 +927,14 @@ class ModelTransaction
*
* @param value the new node value
*/
- public ChangeNodeValueOperation(Object value)
+ public ChangeNodeValueOperation(final Object value)
{
newValue = value;
}
@Override
- protected ImmutableNode apply(ImmutableNode target,
- Operations operations)
+ protected ImmutableNode apply(final ImmutableNode target,
+ final Operations operations)
{
return target.setValue(newValue);
}
@@ -954,14 +954,14 @@ class ModelTransaction
*
* @param name the new node name
*/
- public ChangeNodeNameOperation(String name)
+ public ChangeNodeNameOperation(final String name)
{
newName = name;
}
@Override
- protected ImmutableNode apply(ImmutableNode target,
- Operations operations)
+ protected ImmutableNode apply(final ImmutableNode target,
+ final Operations operations)
{
return target.setName(newName);
}
@@ -990,7 +990,7 @@ class ModelTransaction
*
* @param co the operation
*/
- public void addChildrenOperation(ChildrenUpdateOperation co)
+ public void addChildrenOperation(final ChildrenUpdateOperation co)
{
if (childrenOperation == null)
{
@@ -1007,7 +1007,7 @@ class ModelTransaction
*
* @param op the operation
*/
- public void addOperation(Operation op)
+ public void addOperation(final Operation op)
{
operations = append(operations, op);
}
@@ -1019,7 +1019,7 @@ class ModelTransaction
*
* @param newNodes the collection of newly added nodes
*/
- public void newNodesAdded(Collection<ImmutableNode> newNodes)
+ public void newNodesAdded(final Collection<ImmutableNode> newNodes)
{
addedNodesInOperation =
concatenate(addedNodesInOperation, newNodes);
@@ -1035,7 +1035,7 @@ class ModelTransaction
* @param target the target node for this operation
* @param level the level of the target node
*/
- public void apply(ImmutableNode target, int level)
+ public void apply(final ImmutableNode target, final int level)
{
ImmutableNode node = target;
if (childrenOperation != null)
@@ -1045,7 +1045,7 @@ class ModelTransaction
if (operations != null)
{
- for (Operation op : operations)
+ for (final Operation op : operations)
{
node = op.apply(node, this);
}
@@ -1074,11 +1074,11 @@ class ModelTransaction
* @param node the resulting node after applying all operations
* @param level the level of the target node
*/
- private void propagateChange(ImmutableNode target, ImmutableNode node,
- int level)
+ private void propagateChange(final ImmutableNode target, final ImmutableNode node,
+ final int level)
{
- ImmutableNode parent = getParent(target);
- ChildrenUpdateOperation co = new ChildrenUpdateOperation();
+ final ImmutableNode parent = getParent(target);
+ final ChildrenUpdateOperation co = new ChildrenUpdateOperation();
if (InMemoryNodeModel.checkIfNodeDefined(node))
{
co.addNodeToReplace(target, node);
@@ -1096,11 +1096,11 @@ class ModelTransaction
*
* @param node the resulting node after applying all operations
*/
- private void handleAddedNodes(ImmutableNode node)
+ private void handleAddedNodes(final ImmutableNode node)
{
if (addedNodesInOperation != null)
{
- for (ImmutableNode child : addedNodesInOperation)
+ for (final ImmutableNode child : addedNodesInOperation)
{
parentMapping.put(child, node);
addedNodes.add(child);
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeAddData.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeAddData.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeAddData.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeAddData.java Thu Sep 27 22:24:23 2018
@@ -75,8 +75,8 @@ public class NodeAddData<T>
* @param isAttr flag whether the new node is an attribute
* @param intermediateNodes an optional collection with path nodes
*/
- public NodeAddData(T parentNode, String newName, boolean isAttr,
- Collection<String> intermediateNodes)
+ public NodeAddData(final T parentNode, final String newName, final boolean isAttr,
+ final Collection<String> intermediateNodes)
{
parent = parentNode;
newNodeName = newName;
@@ -141,7 +141,7 @@ public class NodeAddData<T>
* @return an unmodifiable list of path nodes
*/
private static List<String> createPathNodes(
- Collection<String> intermediateNodes)
+ final Collection<String> intermediateNodes)
{
if (intermediateNodes == null)
{
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeCombiner.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeCombiner.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeCombiner.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeCombiner.java Thu Sep 27 22:24:23 2018
@@ -75,7 +75,7 @@ public abstract class NodeCombiner
*
* @param nodeName the name to be added
*/
- public void addListNode(String nodeName)
+ public void addListNode(final String nodeName)
{
listNodes.add(nodeName);
}
@@ -98,7 +98,7 @@ public abstract class NodeCombiner
* @param node the node to be tested
* @return a flag whether this is a list node
*/
- public boolean isListNode(ImmutableNode node)
+ public boolean isListNode(final ImmutableNode node)
{
return listNodes.contains(node.getNodeName());
}
@@ -126,7 +126,7 @@ public abstract class NodeCombiner
return new AbstractImmutableNodeHandler()
{
@Override
- public ImmutableNode getParent(ImmutableNode node)
+ public ImmutableNode getParent(final ImmutableNode node)
{
return null;
}
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeHandlerDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeHandlerDecorator.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeHandlerDecorator.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeHandlerDecorator.java Thu Sep 27 22:24:23 2018
@@ -38,89 +38,89 @@ import java.util.Set;
public abstract class NodeHandlerDecorator<T> implements NodeHandler<T>
{
@Override
- public String nodeName(T node)
+ public String nodeName(final T node)
{
return getDecoratedNodeHandler().nodeName(node);
}
@Override
- public Object getValue(T node)
+ public Object getValue(final T node)
{
return getDecoratedNodeHandler().getValue(node);
}
@Override
- public T getParent(T node)
+ public T getParent(final T node)
{
return getDecoratedNodeHandler().getParent(node);
}
@Override
- public List<T> getChildren(T node)
+ public List<T> getChildren(final T node)
{
return getDecoratedNodeHandler().getChildren(node);
}
@Override
- public <C> List<T> getMatchingChildren(T node, NodeMatcher<C> matcher,
- C criterion)
+ public <C> List<T> getMatchingChildren(final T node, final NodeMatcher<C> matcher,
+ final C criterion)
{
return getDecoratedNodeHandler().getMatchingChildren(node, matcher,
criterion);
}
@Override
- public <C> int getMatchingChildrenCount(T node, NodeMatcher<C> matcher,
- C criterion)
+ public <C> int getMatchingChildrenCount(final T node, final NodeMatcher<C> matcher,
+ final C criterion)
{
return getDecoratedNodeHandler().getMatchingChildrenCount(node,
matcher, criterion);
}
@Override
- public List<T> getChildren(T node, String name)
+ public List<T> getChildren(final T node, final String name)
{
return getDecoratedNodeHandler().getChildren(node, name);
}
@Override
- public T getChild(T node, int index)
+ public T getChild(final T node, final int index)
{
return getDecoratedNodeHandler().getChild(node, index);
}
@Override
- public int indexOfChild(T parent, T child)
+ public int indexOfChild(final T parent, final T child)
{
return getDecoratedNodeHandler().indexOfChild(parent, child);
}
@Override
- public int getChildrenCount(T node, String name)
+ public int getChildrenCount(final T node, final String name)
{
return getDecoratedNodeHandler().getChildrenCount(node, name);
}
@Override
- public Set<String> getAttributes(T node)
+ public Set<String> getAttributes(final T node)
{
return getDecoratedNodeHandler().getAttributes(node);
}
@Override
- public boolean hasAttributes(T node)
+ public boolean hasAttributes(final T node)
{
return getDecoratedNodeHandler().hasAttributes(node);
}
@Override
- public Object getAttributeValue(T node, String name)
+ public Object getAttributeValue(final T node, final String name)
{
return getDecoratedNodeHandler().getAttributeValue(node, name);
}
@Override
- public boolean isDefined(T node)
+ public boolean isDefined(final T node)
{
return getDecoratedNodeHandler().isDefined(node);
}
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeNameMatchers.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeNameMatchers.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeNameMatchers.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeNameMatchers.java Thu Sep 27 22:24:23 2018
@@ -43,8 +43,8 @@ public enum NodeNameMatchers implements
EQUALS
{
@Override
- public <T> boolean matches(T node, NodeHandler<T> handler,
- String criterion)
+ public <T> boolean matches(final T node, final NodeHandler<T> handler,
+ final String criterion)
{
return StringUtils.equals(criterion, handler.nodeName(node));
}
@@ -57,8 +57,8 @@ public enum NodeNameMatchers implements
EQUALS_IGNORE_CASE
{
@Override
- public <T> boolean matches(T node, NodeHandler<T> handler,
- String criterion)
+ public <T> boolean matches(final T node, final NodeHandler<T> handler,
+ final String criterion)
{
return StringUtils.equalsIgnoreCase(criterion,
handler.nodeName(node));
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeSelector.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeSelector.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeSelector.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/NodeSelector.java Thu Sep 27 22:24:23 2018
@@ -57,7 +57,7 @@ public class NodeSelector
*
* @param key the key
*/
- public NodeSelector(String key)
+ public NodeSelector(final String key)
{
this(Collections.singletonList(key));
}
@@ -68,7 +68,7 @@ public class NodeSelector
*
* @param keys the keys for selecting nodes
*/
- private NodeSelector(List<String> keys)
+ private NodeSelector(final List<String> keys)
{
nodeKeys = keys;
}
@@ -84,20 +84,20 @@ public class NodeSelector
* @param handler the {@code NodeHandler}
* @return the selected target node or <b>null</b>
*/
- public ImmutableNode select(ImmutableNode root,
- NodeKeyResolver<ImmutableNode> resolver,
- NodeHandler<ImmutableNode> handler)
+ public ImmutableNode select(final ImmutableNode root,
+ final NodeKeyResolver<ImmutableNode> resolver,
+ final NodeHandler<ImmutableNode> handler)
{
List<ImmutableNode> nodes = new LinkedList<>();
- Iterator<String> itKeys = nodeKeys.iterator();
+ final Iterator<String> itKeys = nodeKeys.iterator();
getFilteredResults(root, resolver, handler, itKeys.next(), nodes);
while (itKeys.hasNext())
{
- String currentKey = itKeys.next();
- List<ImmutableNode> currentResults =
+ final String currentKey = itKeys.next();
+ final List<ImmutableNode> currentResults =
new LinkedList<>();
- for (ImmutableNode currentRoot : nodes)
+ for (final ImmutableNode currentRoot : nodes)
{
getFilteredResults(currentRoot, resolver, handler, currentKey,
currentResults);
@@ -117,9 +117,9 @@ public class NodeSelector
* @param subKey the additional key for the sub selector
* @return the sub {@code NodeSelector} instance
*/
- public NodeSelector subSelector(String subKey)
+ public NodeSelector subSelector(final String subKey)
{
- List<String> keys = new ArrayList<>(nodeKeys.size() + 1);
+ final List<String> keys = new ArrayList<>(nodeKeys.size() + 1);
keys.addAll(nodeKeys);
keys.add(subKey);
return new NodeSelector(keys);
@@ -134,7 +134,7 @@ public class NodeSelector
* @return a flag whether these objects are equal
*/
@Override
- public boolean equals(Object obj)
+ public boolean equals(final Object obj)
{
if (this == obj)
{
@@ -145,7 +145,7 @@ public class NodeSelector
return false;
}
- NodeSelector c = (NodeSelector) obj;
+ final NodeSelector c = (NodeSelector) obj;
return nodeKeys.equals(c.nodeKeys);
}
@@ -181,14 +181,14 @@ public class NodeSelector
* @param key the key
* @param nodes here the results are stored
*/
- private void getFilteredResults(ImmutableNode root,
- NodeKeyResolver<ImmutableNode> resolver,
- NodeHandler<ImmutableNode> handler, String key,
- List<ImmutableNode> nodes)
+ private void getFilteredResults(final ImmutableNode root,
+ final NodeKeyResolver<ImmutableNode> resolver,
+ final NodeHandler<ImmutableNode> handler, final String key,
+ final List<ImmutableNode> nodes)
{
- List<QueryResult<ImmutableNode>> results =
+ final List<QueryResult<ImmutableNode>> results =
resolver.resolveKey(root, key, handler);
- for (QueryResult<ImmutableNode> result : results)
+ for (final QueryResult<ImmutableNode> result : results)
{
if (!result.isAttributeResult())
{