import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
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.IncorrectDataStructureException;
import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.IncorrectDataStructureException;
import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-final class ValueNodeModificationStrategy<T extends DataSchemaNode> extends SchemaAwareApplyOperation<T> {
- private final Class<? extends ValueNode> nodeClass;
+final class ValueNodeModificationStrategy<T extends DataSchemaNode, V extends NormalizedNode<?, ?>>
+ extends SchemaAwareApplyOperation<T> {
+ private final @NonNull Class<V> nodeClass;
- throw new UnsupportedOperationException("Node " + schema.getPath()
- + " is leaf type node. Subtree change is not allowed.");
+ throw new UnsupportedOperationException("Node " + schema + " is leaf type node. "
+ + " Subtree change is not allowed.");
@Override
protected TreeNode applyWrite(final ModifiedNode modification, final NormalizedNode<?, ?> newValue,
@Override
protected TreeNode applyWrite(final ModifiedNode modification, final NormalizedNode<?, ?> newValue,
return TreeNodeFactory.createTreeNode(newValue, version);
}
@Override
protected void checkTouchApplicable(final ModificationPath path, final NodeModification modification,
return TreeNodeFactory.createTreeNode(newValue, version);
}
@Override
protected void checkTouchApplicable(final ModificationPath path, final NodeModification modification,
private void verifyWrittenValue(final NormalizedNode<?, ?> value) {
checkArgument(nodeClass.isInstance(value), "Expected an instance of %s, have %s", nodeClass, value);
}
private void verifyWrittenValue(final NormalizedNode<?, ?> value) {
checkArgument(nodeClass.isInstance(value), "Expected an instance of %s, have %s", nodeClass, value);
}