*/
package org.opendaylight.yangtools.yang.data.impl.schema.tree;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
+import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
private final ModifiedNode modification;
private OperationWithModification(final ModificationApplyOperation op, final ModifiedNode mod) {
- this.applyOperation = Preconditions.checkNotNull(op);
- this.modification = Preconditions.checkNotNull(mod);
+ this.applyOperation = requireNonNull(op);
+ this.modification = requireNonNull(mod);
}
void write(final NormalizedNode<?, ?> value) {
/**
* Fast validation of structure, full validation on written data will be run during seal.
*/
- applyOperation.verifyStructure(value, false);
+ applyOperation.quickVerifyStructure(value);
}
void merge(final NormalizedNode<?, ?> data, final Version version) {
* We perform only quick validation here, full validation will be applied as-needed during
* preparation, as the merge is reconciled with current state.
*/
- applyOperation.verifyStructure(data, false);
+ applyOperation.quickVerifyStructure(data);
applyOperation.mergeIntoModifiedNode(modification, data, version);
}
/**
* Read a particular child. If the child has been modified and does not have a stable
* view, one will we instantiated with specified version.
- *
- * @param child
- * @param version
- * @return
*/
Optional<NormalizedNode<?, ?>> read(final PathArgument child, final Version version) {
final Optional<ModifiedNode> maybeChild = modification.getChild(child);
if (maybeChild.isPresent()) {
final ModifiedNode childNode = maybeChild.get();
- Optional<TreeNode> snapshot = childNode.getSnapshot();
+ Optional<? extends TreeNode> snapshot = childNode.getSnapshot();
if (snapshot == null) {
// Snapshot is not present, force instantiation
snapshot = applyOperation.getChild(child).get().apply(childNode, childNode.getOriginal(), version);
}
- return snapshot.transform(TreeNode::getData);
+ return snapshot.map(TreeNode::getData);
}
- Optional<TreeNode> snapshot = modification.getSnapshot();
+ Optional<? extends TreeNode> snapshot = modification.getSnapshot();
if (snapshot == null) {
snapshot = apply(modification.getOriginal(), version);
}
if (snapshot.isPresent()) {
- return snapshot.get().getChild(child).transform(TreeNode::getData);
+ return snapshot.get().getChild(child).map(TreeNode::getData);
}
- return Optional.absent();
+ return Optional.empty();
}
public ModifiedNode getModification() {
return applyOperation;
}
- public Optional<TreeNode> apply(final Optional<TreeNode> data, final Version version) {
+ public Optional<? extends TreeNode> apply(final Optional<? extends TreeNode> data, final Version version) {
return applyOperation.apply(modification, data, version);
}