2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.data.tree.impl;
10 import java.util.Collection;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.yangtools.concepts.Identifiable;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.data.tree.impl.node.TreeNode;
18 * Internal interface representing a modification action of a particular node. It is used by the validation code to
19 * allow for a read-only view of the modification tree as we should never modify that during validation.
21 abstract sealed class NodeModification implements Identifiable<PathArgument> permits ModifiedNode {
23 * Get the type of modification.
25 * @return Operation type.
27 abstract LogicalOperation getOperation();
30 * Get the original tree node to which the modification is to be applied.
32 * @return The original node, or {@link Optional#absent()} if the node is a new node.
34 // FIXME: we should not need this method
35 final Optional<? extends TreeNode> getOriginal() {
36 return Optional.ofNullable(original());
40 * Get the original tree node to which the modification is to be applied.
42 * @return The original node, or {@code null} if the node is a new node.
44 abstract @Nullable TreeNode original();
47 * Get a read-only view of children nodes.
49 * @return Collection of all children nodes.
51 abstract Collection<? extends NodeModification> getChildren();
54 * A shortcut to {@code getChildren().isEmpty()}.
56 * @return {@code} if {@link #getChildren()} is empty.
58 abstract boolean isEmpty();