import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@Beta
throw new UnsupportedOperationException();
}
+ /**
+ * Return an empty {@link DataTreeCandidateNode} identified by specified {@link PathArgument}.
+ * @param identifier Node identifier
+ * @return An empty DataTreeCandidateNode
+ */
+ public static DataTreeCandidateNode empty(final PathArgument identifier) {
+ return new EmptyDataTreeCandidateNode(identifier);
+ }
+
public static DataTreeCandidateNode fromNormalizedNode(final NormalizedNode<?, ?> node) {
return new NormalizedNodeDataTreeCandidateNode(node);
}
/**
* Applies the {@code node} to the {@code cursor}, note that if the top node of (@code node} is RootNode
- * you need to use {@link #applyRootedNodeToCursor(DataTreeModificationCursor, YangInstanceIdentifier, DataTreeCandidateNode) applyRootedNodeToCursor}
- * method that works with rooted node candidates
+ * you need to use {@link #applyRootedNodeToCursor(DataTreeModificationCursor, YangInstanceIdentifier,
+ * DataTreeCandidateNode) applyRootedNodeToCursor} method that works with rooted node candidates.
+ *
* @param cursor cursor from the modification we want to apply the {@code node} to
* @param node candidate tree to apply
*/
/**
* Applies the {@code node} that is rooted(doesn't have an identifier) in tree A to tree B's {@code cursor}
- * at location specified by {@code rootPath}
+ * at location specified by {@code rootPath}.
+ *
* @param cursor cursor from the modification we want to apply the {@code node} to
* @param rootPath path in the {@code cursor}'s tree we want to apply to candidate to
* @param node candidate tree to apply
*/
- public static void applyRootedNodeToCursor(final DataTreeModificationCursor cursor, final YangInstanceIdentifier rootPath, final DataTreeCandidateNode node) {
+ public static void applyRootedNodeToCursor(final DataTreeModificationCursor cursor,
+ final YangInstanceIdentifier rootPath, final DataTreeCandidateNode node) {
switch (node.getModificationType()) {
case DELETE:
cursor.delete(rootPath.getLastPathArgument());
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.data.api.schema.tree;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+final class EmptyDataTreeCandidateNode implements DataTreeCandidateNode {
+
+ private final PathArgument identifier;
+
+ EmptyDataTreeCandidateNode(final PathArgument identifier) {
+ this.identifier = Preconditions.checkNotNull(identifier, "Identifier should not be null");
+ }
+
+ @Nonnull
+ @Override
+ public PathArgument getIdentifier() {
+ return identifier;
+ }
+
+ @Nonnull
+ @Override
+ public Collection<DataTreeCandidateNode> getChildNodes() {
+ return ImmutableList.of();
+ }
+
+ @Nullable
+ @Override
+ public DataTreeCandidateNode getModifiedChild(final PathArgument identifier) {
+ return null;
+ }
+
+ @Nonnull
+ @Override
+ public ModificationType getModificationType() {
+ return ModificationType.UNMODIFIED;
+ }
+
+ @Nonnull
+ @Override
+ public Optional<NormalizedNode<?, ?>> getDataAfter() {
+ return Optional.absent();
+ }
+
+ @Nonnull
+ @Override
+ public Optional<NormalizedNode<?, ?>> getDataBefore() {
+ return Optional.absent();
+ }
+}
\ No newline at end of file