import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
+import com.google.common.base.Verify;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
private LogicalOperation operation = LogicalOperation.NONE;
private Optional<TreeNode> snapshotCache;
private NormalizedNode<?, ?> value;
+ private ModificationType modType;
private ModifiedNode(final PathArgument identifier, final Optional<TreeNode> original, final boolean isOrdered) {
this.identifier = identifier;
return original;
}
-
@Override
LogicalOperation getOperation() {
return operation;
ModifiedNode modifyChild(final PathArgument child, final boolean isOrdered) {
clearSnapshot();
if (operation == LogicalOperation.NONE) {
- updateModificationType(LogicalOperation.TOUCH);
+ updateOperationType(LogicalOperation.TOUCH);
}
final ModifiedNode potential = children.get(child);
if (potential != null) {
clearSnapshot();
children.clear();
this.value = null;
- updateModificationType(newType);
+ updateOperationType(newType);
}
/**
*/
void write(final NormalizedNode<?, ?> value) {
clearSnapshot();
- updateModificationType(LogicalOperation.WRITE);
+ updateOperationType(LogicalOperation.WRITE);
children.clear();
this.value = value;
}
void merge(final NormalizedNode<?, ?> value) {
clearSnapshot();
- updateModificationType(LogicalOperation.MERGE);
+ updateOperationType(LogicalOperation.MERGE);
/*
* Blind overwrite of any previous data is okay, no matter whether the node
// A TOUCH node without any children is a no-op
if (operation == LogicalOperation.TOUCH && children.isEmpty()) {
- updateModificationType(LogicalOperation.NONE);
+ updateOperationType(LogicalOperation.NONE);
}
}
return snapshot;
}
- private void updateModificationType(final LogicalOperation type) {
+ private void updateOperationType(final LogicalOperation type) {
operation = type;
+ modType = null;
clearSnapshot();
}
+ operation + ", childModification=" + children + "]";
}
+ void resolveModificationType(@Nonnull final ModificationType type) {
+ modType = type;
+ }
+
+ @Nonnull ModificationType modificationType() {
+ return Verify.verifyNotNull(modType, "Node %s does not have resolved modification type", this);
+ }
+
/**
* Create a node which will reflect the state of this node, except it will behave as newly-written
* value. This is useful only for merge validation.