import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.util.ModifiableMapPhase;
import org.opendaylight.yangtools.util.UnmodifiableMapPhase;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
}
}
- private Map<PathArgument, Object> value;
+ private Map<NodeIdentifier, Object> value;
private I nodeIdentifier;
/*
return nodeIdentifier;
}
- protected final @Nullable DataContainerChild getChild(final PathArgument child) {
+ protected final @Nullable DataContainerChild getChild(final NodeIdentifier child) {
return LazyLeafOperations.getChild(value, child);
}
- protected final Map<PathArgument, Object> buildValue() {
+ protected final Map<NodeIdentifier, Object> buildValue() {
if (value instanceof ModifiableMapPhase) {
- return ((ModifiableMapPhase<PathArgument, Object>)value).toUnmodifiableMap();
+ return ((ModifiableMapPhase<NodeIdentifier, Object>)value).toUnmodifiableMap();
}
dirty = true;
private void checkDirty() {
if (dirty) {
if (value instanceof UnmodifiableMapPhase) {
- value = ((UnmodifiableMapPhase<PathArgument, Object>) value).toModifiableMap();
+ value = ((UnmodifiableMapPhase<NodeIdentifier, Object>) value).toModifiableMap();
} else if (value instanceof CloneableMap) {
- value = ((CloneableMap<PathArgument, Object>) value).createMutableClone();
+ value = ((CloneableMap<NodeIdentifier, Object>) value).createMutableClone();
} else {
value = newHashMap(value);
}
import java.util.Map;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
private static final class ImmutableChoiceNode
extends AbstractImmutableDataContainerNode<NodeIdentifier, ChoiceNode> implements ChoiceNode {
- ImmutableChoiceNode(final NodeIdentifier nodeIdentifier, final Map<PathArgument, Object> children) {
+ ImmutableChoiceNode(final NodeIdentifier nodeIdentifier, final Map<NodeIdentifier, Object> children) {
super(children, nodeIdentifier);
}
import java.util.Map;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
protected static final class ImmutableContainerNode
extends AbstractImmutableDataContainerNode<NodeIdentifier, ContainerNode> implements ContainerNode {
- ImmutableContainerNode(final NodeIdentifier nodeIdentifier, final Map<PathArgument, Object> children) {
+ ImmutableContainerNode(final NodeIdentifier nodeIdentifier, final Map<NodeIdentifier, Object> children) {
super(children, nodeIdentifier);
}
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
-import java.util.Map.Entry;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
public class ImmutableMapEntryNodeBuilder
extends AbstractImmutableDataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> {
private static final Logger LOG = LoggerFactory.getLogger(ImmutableMapEntryNodeBuilder.class);
- // FIXME: NodeIdentifier instead
- protected final Map<QName, PathArgument> childrenQNamesToPaths;
+
+ protected final Map<QName, NodeIdentifier> childrenQNamesToPaths;
protected ImmutableMapEntryNodeBuilder() {
childrenQNamesToPaths = new LinkedHashMap<>();
return new ImmutableMapEntryNodeBuilder(immutableNode);
}
- private static void fillQNames(final Iterable<DataContainerChild> iterable, final Map<QName, PathArgument> out) {
- for (final DataContainerChild child : iterable) {
+ private static void fillQNames(final Iterable<DataContainerChild> iterable, final Map<QName, NodeIdentifier> out) {
+ for (var child : iterable) {
putQName(out, child);
}
}
- private static void putQName(final Map<QName, PathArgument> map, final DataContainerChild child) {
- // Augmentation nodes cannot be keys, and do not have to be present in childrenQNamesToPaths map
+ private static void putQName(final Map<QName, NodeIdentifier> map, final DataContainerChild child) {
final var identifier = child.name();
map.put(identifier.getNodeType(), identifier);
}
@Override
public MapEntryNode build() {
- for (final Entry<QName, Object> key : getNodeIdentifier().entrySet()) {
- final DataContainerChild childNode = getChild(childrenQNamesToPaths.get(key.getKey()));
+ for (var key : getNodeIdentifier().entrySet()) {
+ final var childNode = getChild(childrenQNamesToPaths.get(key.getKey()));
// We have enough information to fill-in missing leaf nodes, so let's do that
if (childNode == null) {
- LeafNode<Object> leaf = ImmutableNodes.leafNode(key.getKey(), key.getValue());
+ final var leaf = ImmutableNodes.leafNode(key.getKey(), key.getValue());
LOG.debug("Adding leaf {} implied by key {}", leaf, key);
withChild(leaf);
} else {
implements MapEntryNode {
ImmutableMapEntryNode(final NodeIdentifierWithPredicates nodeIdentifier,
- final Map<PathArgument, Object> children) {
+ final Map<NodeIdentifier, Object> children) {
super(children, nodeIdentifier);
}
import java.util.Map;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
protected static final class ImmutableUnkeyedListEntryNode
extends AbstractImmutableDataContainerNode<NodeIdentifier, UnkeyedListEntryNode>
implements UnkeyedListEntryNode {
- ImmutableUnkeyedListEntryNode(final NodeIdentifier nodeIdentifier, final Map<PathArgument, Object> children) {
+ ImmutableUnkeyedListEntryNode(final NodeIdentifier nodeIdentifier, final Map<NodeIdentifier, Object> children) {
super(children, nodeIdentifier);
}
public abstract class AbstractImmutableDataContainerNode<K extends PathArgument, N extends DataContainerNode>
extends AbstractNormalizedNode<K, N> implements DataContainerNode {
- private final Map<PathArgument, Object> children;
+ private final Map<NodeIdentifier, Object> children;
- protected AbstractImmutableDataContainerNode(final Map<PathArgument, Object> children, final K nodeIdentifier) {
+ protected AbstractImmutableDataContainerNode(final Map<NodeIdentifier, Object> children, final K nodeIdentifier) {
super(nodeIdentifier);
this.children = ImmutableOffsetMap.unorderedCopyOf(children);
}
*
* @return An unmodifiable view if this node's children.
*/
- public final Map<PathArgument, Object> getChildren() {
+ public final Map<NodeIdentifier, Object> getChildren() {
return children;
}
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
// Hidden on purpose
}
- public static @Nullable DataContainerChild getChild(final Map<PathArgument, Object> map, final PathArgument key) {
+ public static @Nullable DataContainerChild getChild(final Map<NodeIdentifier, Object> map,
+ final NodeIdentifier key) {
final Object value = map.get(key);
return value == null ? null : decodeChild(key, value);
}
- public static void putChild(final Map<PathArgument, Object> map, final DataContainerChild child) {
+ public static void putChild(final Map<NodeIdentifier, Object> map, final DataContainerChild child) {
final var node = requireNonNull(child);
map.put(node.name(), encodeExpendableChild(node));
}
- static @NonNull LeafNode<?> coerceLeaf(final PathArgument key, final Object value) {
- verify(key instanceof NodeIdentifier, "Unexpected value %s for child %s", value, key);
- return ImmutableNodes.leafNode((NodeIdentifier) key, value);
+ static @NonNull LeafNode<?> coerceLeaf(final NodeIdentifier key, final Object value) {
+ return ImmutableNodes.leafNode(key, value);
}
- private static @Nullable DataContainerChild decodeChild(final PathArgument key, final @NonNull Object value) {
+ private static @Nullable DataContainerChild decodeChild(final NodeIdentifier key, final @NonNull Object value) {
return decodeExpendableChild(key, value);
}
- private static @NonNull DataContainerChild decodeExpendableChild(final PathArgument key,
+ private static @NonNull DataContainerChild decodeExpendableChild(final NodeIdentifier key,
final @NonNull Object value) {
return value instanceof DataContainerChild child ? child : coerceLeaf(key, value);
}
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
// This is *almost* the same as Guava's TransformedCollection. The main difference is delegation of hashCode()/equals()
// Collection.equals() is undefined, but the expectation from users is that we will return the same view object, which
// equals on identity.
final class LazyValues extends AbstractCollection<DataContainerChild> {
- private final Map<PathArgument, Object> map;
+ private final Map<NodeIdentifier, Object> map;
- LazyValues(final Map<PathArgument, Object> map) {
+ LazyValues(final Map<NodeIdentifier, Object> map) {
this.map = requireNonNull(map);
}
}
private static final class Iter implements Iterator<DataContainerChild> {
- private final Iterator<Entry<PathArgument, Object>> iterator;
+ private final Iterator<Entry<NodeIdentifier, Object>> iterator;
- Iter(final Iterator<Entry<PathArgument, Object>> iterator) {
+ Iter(final Iterator<Entry<NodeIdentifier, Object>> iterator) {
this.iterator = requireNonNull(iterator);
}