+++ /dev/null
-/*
- * Copyright (c) 2021 PANTHEON.tech, 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.impl.schema;
-
-import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-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.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
-import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.ListNodeBuilder;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAnyXmlNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUserLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ContainerLike;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-
-@Deprecated(forRemoval = true)
-public final class SchemaAwareBuilders {
- private SchemaAwareBuilders() {
- // Hidden on purpose
- }
-
- public static NormalizedNodeBuilder<NodeIdentifier, DOMSource, DOMSourceAnyxmlNode> anyXmlBuilder(
- final AnyxmlSchemaNode schema) {
- return ImmutableAnyXmlNodeBuilder.create(schema);
- }
-
- public static <T> NormalizedNodeBuilder<NodeIdentifier, T, LeafNode<T>> leafBuilder(
- final LeafSchemaNode schema) {
- return ImmutableLeafNodeBuilder.create(schema);
- }
-
- public static <T> NormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> leafSetEntryBuilder(
- final LeafListSchemaNode schema) {
- return ImmutableLeafSetEntryNodeBuilder.create(schema);
- }
-
- public static <T> ListNodeBuilder<T, UserLeafSetNode<T>> orderedLeafSetBuilder(final LeafListSchemaNode schema) {
- return ImmutableUserLeafSetNodeBuilder.create(schema);
- }
-
- public static <T> ListNodeBuilder<T, SystemLeafSetNode<T>> leafSetBuilder(final LeafListSchemaNode schema) {
- return ImmutableLeafSetNodeBuilder.create(schema);
- }
-
- public static <T> ListNodeBuilder<T, SystemLeafSetNode<T>> leafSetBuilder(final LeafListSchemaNode schema,
- final LeafSetNode<T> node) {
- return ImmutableLeafSetNodeBuilder.create(schema, node);
- }
-
- public static DataContainerNodeBuilder<NodeIdentifier, ContainerNode> containerBuilder(final ContainerLike schema) {
- return ImmutableContainerNodeBuilder.create(schema);
- }
-
- public static DataContainerNodeBuilder<NodeIdentifier, ContainerNode> containerBuilder(final ContainerLike schema,
- final ContainerNode node) {
- return ImmutableContainerNodeBuilder.create(schema, node);
- }
-
- public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder(
- final ListSchemaNode schema) {
- return ImmutableMapEntryNodeBuilder.create(schema);
- }
-
- public static CollectionNodeBuilder<MapEntryNode, SystemMapNode> mapBuilder(final ListSchemaNode schema) {
- return ImmutableMapNodeBuilder.create(schema);
- }
-
- public static CollectionNodeBuilder<MapEntryNode, SystemMapNode> mapBuilder(final ListSchemaNode schema,
- final MapNode node) {
- return ImmutableMapNodeBuilder.create(schema, node);
- }
-
- public static DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> augmentationBuilder(
- final AugmentationSchemaNode schema) {
- return ImmutableAugmentationNodeBuilder.create(schema);
- }
-
- public static DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choiceBuilder(final ChoiceSchemaNode schema) {
- return ImmutableChoiceNodeBuilder.create(schema);
- }
-}
import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedSimpleValueNode;
-import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
public class ImmutableAnyXmlNodeBuilder
extends AbstractImmutableNormalizedNodeBuilder<NodeIdentifier, DOMSource, DOMSourceAnyxmlNode> {
return new ImmutableAnyXmlNodeBuilder();
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static @NonNull NormalizedNodeBuilder<NodeIdentifier, DOMSource, DOMSourceAnyxmlNode> create(
- final AnyxmlSchemaNode schema) {
- return new SchemaAwareImmutableAnyXmlNodeBuilder(schema);
- }
-
@Override
public ImmutableAnyXmlNodeBuilder withValue(final DOMSource withValue) {
super.withValue(withValue);
import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
public class ImmutableAugmentationNodeBuilder
extends AbstractImmutableDataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> {
return new ImmutableAugmentationNodeBuilder((ImmutableAugmentationNode)node);
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static @NonNull DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> create(
- final AugmentationSchemaNode schema) {
- return new SchemaAwareImmutableAugmentationNodeBuilder(schema);
- }
-
@Override
public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withChild(
final DataContainerChild child) {
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;
-import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
public class ImmutableChoiceNodeBuilder extends AbstractImmutableDataContainerNodeBuilder<NodeIdentifier, ChoiceNode> {
protected ImmutableChoiceNodeBuilder() {
return new ImmutableChoiceNodeBuilder((ImmutableChoiceNode)node);
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static @NonNull DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> create(final ChoiceSchemaNode schema) {
- return new SchemaAwareImmutableChoiceNodeBuilder(schema);
- }
-
@Override
public ChoiceNode build() {
return new ImmutableChoiceNode(getNodeIdentifier(), buildValue());
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;
-import org.opendaylight.yangtools.yang.model.api.ContainerLike;
public class ImmutableContainerNodeBuilder
extends AbstractImmutableDataContainerNodeBuilder<NodeIdentifier, ContainerNode> {
return new ImmutableContainerNodeBuilder((ImmutableContainerNode) node);
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static @NonNull DataContainerNodeBuilder<NodeIdentifier, ContainerNode> create(final ContainerLike schema) {
- return new SchemaAwareImmutableContainerNodeBuilder(schema);
- }
-
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static @NonNull DataContainerNodeBuilder<NodeIdentifier, ContainerNode> create(final ContainerLike schema,
- final ContainerNode node) {
- if (!(node instanceof ImmutableContainerNode)) {
- throw new UnsupportedOperationException("Cannot initialize from class " + node.getClass());
- }
- return new SchemaAwareImmutableContainerNodeBuilder(schema, (ImmutableContainerNode)node);
- }
-
@Override
public ContainerNode build() {
return new ImmutableContainerNode(getNodeIdentifier(), buildValue());
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedSimpleValueNode;
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
public class ImmutableLeafNodeBuilder<T>
extends AbstractImmutableNormalizedNodeBuilder<NodeIdentifier, T, LeafNode<T>> {
return new ImmutableLeafNodeBuilder<>();
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static <T> @NonNull NormalizedNodeBuilder<NodeIdentifier, T, LeafNode<T>> create(
- final LeafSchemaNode schema) {
- return new SchemaAwareImmutableLeafNodeBuilder<>(schema);
- }
-
@Beta
@SuppressWarnings("unchecked")
public static <T> @NonNull LeafNode<T> createNode(final NodeIdentifier identifier, final T value) {
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedSimpleValueNode;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
public class ImmutableLeafSetEntryNodeBuilder<T>
extends AbstractImmutableNormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> {
return new ImmutableLeafSetEntryNodeBuilder<>();
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static <T> @NonNull NormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> create(
- final LeafListSchemaNode schema) {
- return new SchemaAwareImmutableLeafSetEntryNodeBuilder<>(schema);
- }
-
@Override
public LeafSetEntryNode<T> build() {
return new ImmutableLeafSetEntryNode<>(getNodeIdentifier(), getValue());
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.ListNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedValueNode;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
public class ImmutableLeafSetNodeBuilder<T> implements ListNodeBuilder<T, SystemLeafSetNode<T>> {
private static final int DEFAULT_CAPACITY = 4;
throw new UnsupportedOperationException("Cannot initialize from class " + node.getClass());
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static <T> @NonNull ListNodeBuilder<T, SystemLeafSetNode<T>> create(final LeafListSchemaNode schema) {
- return new SchemaAwareImmutableLeafSetNodeBuilder<>(schema);
- }
-
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static <T> @NonNull ListNodeBuilder<T, SystemLeafSetNode<T>> create(final LeafListSchemaNode schema,
- final LeafSetNode<T> node) {
- if (node instanceof ImmutableLeafSetNode) {
- return new SchemaAwareImmutableLeafSetNodeBuilder<>(schema, (ImmutableLeafSetNode<T>) node);
- }
- throw new UnsupportedOperationException("Cannot initialize from class " + node.getClass());
- }
-
@Override
public ImmutableLeafSetNodeBuilder<T> withChild(final LeafSetEntryNode<T> child) {
this.value.put(child.getIdentifier(), child);
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
protected final Map<QName, PathArgument> childrenQNamesToPaths;
protected ImmutableMapEntryNodeBuilder() {
- this.childrenQNamesToPaths = new LinkedHashMap<>();
+ childrenQNamesToPaths = new LinkedHashMap<>();
}
protected ImmutableMapEntryNodeBuilder(final int sizeHint) {
super(sizeHint);
- this.childrenQNamesToPaths = new LinkedHashMap<>(sizeHint);
+ childrenQNamesToPaths = new LinkedHashMap<>(sizeHint);
}
protected ImmutableMapEntryNodeBuilder(final ImmutableMapEntryNode node) {
super(node);
- this.childrenQNamesToPaths = new LinkedHashMap<>();
+ childrenQNamesToPaths = new LinkedHashMap<>();
fillQNames(node.body(), childrenQNamesToPaths);
}
return new ImmutableMapEntryNodeBuilder((ImmutableMapEntryNode)node);
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static @NonNull DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> create(
- final ListSchemaNode schema) {
- return new SchemaAwareImmutableMapEntryNodeBuilder(schema);
- }
-
private static void fillQNames(final Iterable<DataContainerChild> iterable, final Map<QName, PathArgument> out) {
for (final DataContainerChild child : iterable) {
putQName(out, child);
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.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
import org.opendaylight.yangtools.yang.data.spi.node.AbstractNormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
public class ImmutableMapNodeBuilder implements CollectionNodeBuilder<MapEntryNode, SystemMapNode> {
private static final int DEFAULT_CAPACITY = 4;
return new ImmutableMapNodeBuilder(node);
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static @NonNull CollectionNodeBuilder<MapEntryNode, SystemMapNode> create(final ListSchemaNode schema) {
- return new SchemaAwareImmutableMapNodeBuilder(schema);
- }
-
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static @NonNull CollectionNodeBuilder<MapEntryNode, SystemMapNode> create(final ListSchemaNode schema,
- final MapNode node) {
- if (node instanceof ImmutableMapNode) {
- return new SchemaAwareImmutableMapNodeBuilder(schema, (ImmutableMapNode) node);
- }
- throw new UnsupportedOperationException("Cannot initialize from class " + node.getClass());
- }
-
@Override
public ImmutableMapNodeBuilder withChild(final MapEntryNode child) {
this.value.put(child.getIdentifier(), child);
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.ListNodeBuilder;
import org.opendaylight.yangtools.yang.data.spi.node.AbstractNormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
public class ImmutableUserLeafSetNodeBuilder<T> implements ListNodeBuilder<T, UserLeafSetNode<T>> {
private Map<NodeWithValue, LeafSetEntryNode<T>> value;
return new ImmutableUserLeafSetNodeBuilder<>((ImmutableUserLeafSetNode<T>) node);
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static <T> @NonNull ListNodeBuilder<T, UserLeafSetNode<T>> create(final LeafListSchemaNode schema) {
- return new SchemaAwareImmutableOrderedLeafSetNodeBuilder<>(schema);
- }
-
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static <T> @NonNull ListNodeBuilder<T, UserLeafSetNode<T>> create(final LeafListSchemaNode schema,
- final LeafSetNode<T> node) {
- if (node instanceof ImmutableUserLeafSetNode<?>) {
- return new SchemaAwareImmutableOrderedLeafSetNodeBuilder<>(schema, (ImmutableUserLeafSetNode<T>) node);
- }
- throw new UnsupportedOperationException("Cannot initialize from class " + node.getClass());
- }
-
private void checkDirty() {
if (dirty) {
value = new LinkedHashMap<>(value);
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.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeContainerBuilder;
import org.opendaylight.yangtools.yang.data.spi.node.AbstractNormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
public class ImmutableUserMapNodeBuilder implements CollectionNodeBuilder<MapEntryNode, UserMapNode> {
private static final int DEFAULT_CAPACITY = 4;
private boolean dirty;
ImmutableUserMapNodeBuilder() {
- this.value = new LinkedHashMap<>(DEFAULT_CAPACITY);
- this.dirty = false;
+ value = new LinkedHashMap<>(DEFAULT_CAPACITY);
+ dirty = false;
}
private ImmutableUserMapNodeBuilder(final int sizeHint) {
if (sizeHint >= 0) {
- this.value = new LinkedHashMap<>(sizeHint + sizeHint / 3);
+ value = new LinkedHashMap<>(sizeHint + sizeHint / 3);
} else {
- this.value = new LinkedHashMap<>(DEFAULT_CAPACITY);
+ value = new LinkedHashMap<>(DEFAULT_CAPACITY);
}
- this.dirty = false;
+ dirty = false;
}
- ImmutableUserMapNodeBuilder(final ImmutableUserMapNode node) {
- this.nodeIdentifier = node.getIdentifier();
- this.value = node.children;
- this.dirty = true;
+ private ImmutableUserMapNodeBuilder(final ImmutableUserMapNode node) {
+ nodeIdentifier = node.getIdentifier();
+ value = node.children;
+ dirty = true;
}
public static @NonNull CollectionNodeBuilder<MapEntryNode, UserMapNode> create() {
return new ImmutableUserMapNodeBuilder((ImmutableUserMapNode) node);
}
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static @NonNull CollectionNodeBuilder<MapEntryNode, UserMapNode> create(final ListSchemaNode schema) {
- return new SchemaAwareImmutableOrderedMapNodeBuilder(schema);
- }
-
- @Deprecated(since = "6.0.7", forRemoval = true)
- public static @NonNull CollectionNodeBuilder<MapEntryNode, UserMapNode> create(final ListSchemaNode schema,
- final MapNode node) {
- if (node instanceof ImmutableUserMapNode) {
- return new SchemaAwareImmutableOrderedMapNodeBuilder(schema, (ImmutableUserMapNode) node);
- }
- throw new UnsupportedOperationException("Cannot initialize from class " + node.getClass());
- }
-
private void checkDirty() {
if (dirty) {
value = new LinkedHashMap<>(value);
@Override
public CollectionNodeBuilder<MapEntryNode, UserMapNode> withChild(final MapEntryNode child) {
checkDirty();
- this.value.put(child.getIdentifier(), child);
+ value.put(child.getIdentifier(), child);
return this;
}
@Override
public CollectionNodeBuilder<MapEntryNode, UserMapNode> withoutChild(final PathArgument key) {
checkDirty();
- this.value.remove(key);
+ value.remove(key);
return this;
}
@Override
public CollectionNodeBuilder<MapEntryNode, UserMapNode> withNodeIdentifier(
final NodeIdentifier withNodeIdentifier) {
- this.nodeIdentifier = withNodeIdentifier;
+ nodeIdentifier = withNodeIdentifier;
return this;
}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
-
-final class SchemaAwareImmutableAnyXmlNodeBuilder extends ImmutableAnyXmlNodeBuilder {
- SchemaAwareImmutableAnyXmlNodeBuilder(final AnyxmlSchemaNode schema) {
- super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
- }
-
- @Override
- public ImmutableAnyXmlNodeBuilder withValue(final DOMSource withValue) {
- return super.withValue(withValue);
- }
-
- @Override
- public NormalizedNodeBuilder<NodeIdentifier, DOMSource, DOMSourceAnyxmlNode> withNodeIdentifier(
- final NodeIdentifier withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataNodeContainerValidator;
-import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
-
-final class SchemaAwareImmutableAugmentationNodeBuilder extends ImmutableAugmentationNodeBuilder {
- private final DataNodeContainerValidator validator;
-
- SchemaAwareImmutableAugmentationNodeBuilder(final AugmentationSchemaNode schema) {
- this.validator = new DataNodeContainerValidator(schema);
- super.withNodeIdentifier(DataSchemaContextNode.augmentationIdentifierFrom(schema));
- }
-
- @Override
- public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withNodeIdentifier(
- final AugmentationIdentifier withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-
- @Override
- public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withChild(
- final DataContainerChild child) {
- return super.withChild(validator.validateChild(child));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.Optional;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataNodeContainerValidator;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
-import org.opendaylight.yangtools.yang.data.util.NormalizedNodeSchemaUtils;
-import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
-
-final class SchemaAwareImmutableChoiceNodeBuilder extends ImmutableChoiceNodeBuilder {
- private final ChoiceSchemaNode schema;
- private DataNodeContainerValidator validator;
-
- SchemaAwareImmutableChoiceNodeBuilder(final ChoiceSchemaNode schema) {
- this.schema = requireNonNull(schema, "Schema was null");
- super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
- }
-
- @Override
- public DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> withNodeIdentifier(
- final NodeIdentifier withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-
- @Override
- public DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> withChild(final DataContainerChild child) {
- if (validator == null) {
- Optional<CaseSchemaNode> detectedCaseOpt = NormalizedNodeSchemaUtils.detectCase(schema, child);
- DataValidationException.checkLegalChild(detectedCaseOpt.isPresent(), child.getIdentifier(), schema);
- validator = new DataNodeContainerValidator(detectedCaseOpt.get());
- }
-
- return super.withChild(validator.validateChild(child));
- }
-
- @Override
- public ChoiceNode build() {
- // TODO validate when statement
- return super.build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataNodeContainerValidator;
-import org.opendaylight.yangtools.yang.model.api.ContainerLike;
-
-public final class SchemaAwareImmutableContainerNodeBuilder extends ImmutableContainerNodeBuilder {
- private final DataNodeContainerValidator validator;
-
- SchemaAwareImmutableContainerNodeBuilder(final ContainerLike schema) {
- this.validator = new DataNodeContainerValidator(schema);
- super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
- }
-
- SchemaAwareImmutableContainerNodeBuilder(final ContainerLike schema, final ImmutableContainerNode node) {
- super(node);
- this.validator = new DataNodeContainerValidator(schema);
- super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
- }
-
- @Override
- public DataContainerNodeBuilder<NodeIdentifier, ContainerNode> withNodeIdentifier(
- final NodeIdentifier withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-
- @Override
- public DataContainerNodeBuilder<NodeIdentifier, ContainerNode> withChild(final DataContainerChild child) {
- validator.validateChild(child.getIdentifier());
- return super.withChild(child);
- }
-
- @Override
- public ContainerNode build() {
- // TODO check when statements... somewhere
- return super.build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-
-final class SchemaAwareImmutableLeafNodeBuilder<T> extends ImmutableLeafNodeBuilder<T> {
- SchemaAwareImmutableLeafNodeBuilder(final LeafSchemaNode schema) {
- super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
- }
-
- @Override
- public NormalizedNodeBuilder<NodeIdentifier, T, LeafNode<T>> withValue(final T withValue) {
- // TODO: check value type
- return super.withValue(withValue);
- }
-
- @Override
- public NormalizedNodeBuilder<NodeIdentifier, T, LeafNode<T>> withNodeIdentifier(
- final NodeIdentifier withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-
-final class SchemaAwareImmutableLeafSetEntryNodeBuilder<T> extends ImmutableLeafSetEntryNodeBuilder<T> {
- private final LeafListSchemaNode schema;
-
- SchemaAwareImmutableLeafSetEntryNodeBuilder(final LeafListSchemaNode schema) {
- this.schema = requireNonNull(schema);
- }
-
- @Override
- public NormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withValue(final T withValue) {
- super.withNodeIdentifier(new NodeWithValue<>(schema.getQName(), withValue));
- // TODO check value type using TypeProvider ?
- return super.withValue(withValue);
- }
-
- @Override
- public NormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withNodeIdentifier(
- final NodeWithValue withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.Objects.requireNonNull;
-
-import java.util.Set;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-
-final class SchemaAwareImmutableLeafSetNodeBuilder<T> extends ImmutableLeafSetNodeBuilder<T> {
- private final LeafListSchemaNode schema;
-
- SchemaAwareImmutableLeafSetNodeBuilder(final LeafListSchemaNode schema) {
- this.schema = requireNonNull(schema);
- super.withNodeIdentifier(new NodeIdentifier(schema.getQName()));
- }
-
- SchemaAwareImmutableLeafSetNodeBuilder(final LeafListSchemaNode schema, final ImmutableLeafSetNode<T> node) {
- super(node);
- this.schema = requireNonNull(schema);
- // FIXME: Preconditions.checkArgument(schema.getQName().equals(node.getIdentifier()));
- super.withNodeIdentifier(new NodeIdentifier(schema.getQName()));
- }
-
- @Override
- public ImmutableLeafSetNodeBuilder<T> withChildValue(final T childValue) {
- // TODO check value type
- return super.withChildValue(childValue);
- }
-
- @Override
- public ImmutableLeafSetNodeBuilder<T> withChild(final LeafSetEntryNode<T> child) {
- final NodeWithValue<T> childId = child.getIdentifier();
- final QName childName = childId.getNodeType();
- final QName qname = schema.getQName();
-
- checkArgument(qname.equals(childName), "Incompatible node type, should be: %s, is: %s", qname, childName);
- // TODO check value type using TypeProvider ?
- DataValidationException.checkLegalChild(qname.equals(childName), childId, schema, Set.of(qname));
- return super.withChild(child);
- }
-
- @Override
- public ImmutableLeafSetNodeBuilder<T> withNodeIdentifier(final NodeIdentifier withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ImmutableMap;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.opendaylight.yangtools.util.ImmutableMapTemplate;
-import org.opendaylight.yangtools.yang.common.QName;
-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.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataNodeContainerValidator;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException.IllegalListKeyException;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-
-final class SchemaAwareImmutableMapEntryNodeBuilder extends ImmutableMapEntryNodeBuilder {
- private final ListSchemaNode schema;
- private final DataNodeContainerValidator validator;
-
- SchemaAwareImmutableMapEntryNodeBuilder(final ListSchemaNode schema) {
- this.schema = requireNonNull(schema);
- this.validator = new DataNodeContainerValidator(schema);
- }
-
- @Override
- public ImmutableMapEntryNodeBuilder withNodeIdentifier(final NodeIdentifierWithPredicates withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-
- @Override
- public DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> withChild(
- final DataContainerChild child) {
- validator.validateChild(child.getIdentifier());
- return super.withChild(child);
- }
-
- @Override
- public MapEntryNode build() {
- super.withNodeIdentifier(constructNodeIdentifier());
- return super.build();
- }
-
- /**
- * Build map entry node identifier from schema and provided children.
- */
- private NodeIdentifierWithPredicates constructNodeIdentifier() {
- final Map<QName, Object> predicates;
- final Collection<QName> keys = schema.getKeyDefinition();
- if (!keys.isEmpty()) {
- predicates = keyDefToPredicates(keys);
- } else if (!childrenQNamesToPaths.isEmpty()) {
- predicates = childrenToPredicates();
- } else {
- predicates = ImmutableMap.of();
- }
- return NodeIdentifierWithPredicates.of(schema.getQName(), predicates);
- }
-
- private Map<QName, Object> childrenToPredicates() {
- final Object[] values = new Object[childrenQNamesToPaths.size()];
- int offset = 0;
- for (Entry<QName, PathArgument> entry : childrenQNamesToPaths.entrySet()) {
- values[offset++] = nonnullKeyValue(entry.getKey(), getChild(entry.getValue())).body();
- }
- return ImmutableMapTemplate.ordered(childrenQNamesToPaths.keySet()).instantiateWithValues(values);
- }
-
- private Map<QName, Object> keyDefToPredicates(final Collection<QName> keys) {
- final Object[] values = new Object[keys.size()];
- int offset = 0;
- for (QName key : keys) {
- values[offset++] = nonnullKeyValue(key, getChild(childrenQNamesToPaths.get(key))).body();
- }
- return ImmutableMapTemplate.ordered(keys).instantiateWithValues(values);
- }
-
- private DataContainerChild nonnullKeyValue(final QName key, final DataContainerChild value) {
- if (value != null) {
- return value;
- }
- throw new IllegalListKeyException("Key value not present for key: %s, in: %s values %s", key, schema.getQName(),
- buildValue());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.Set;
-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.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-
-final class SchemaAwareImmutableMapNodeBuilder extends ImmutableMapNodeBuilder {
- private final ListSchemaNode schema;
-
- SchemaAwareImmutableMapNodeBuilder(final ListSchemaNode schema) {
- this.schema = requireNonNull(schema);
- super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
- }
-
- SchemaAwareImmutableMapNodeBuilder(final ListSchemaNode schema, final ImmutableMapNode node) {
- super(node);
- this.schema = requireNonNull(schema);
- super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
- }
-
- @Override
- public ImmutableMapNodeBuilder withChild(final MapEntryNode child) {
- final NodeIdentifierWithPredicates childId = child.getIdentifier();
- final QName qname = schema.getQName();
-
- DataValidationException.checkLegalChild(qname.equals(childId.getNodeType()), childId, schema, Set.of(qname));
- return super.withChild(child);
- }
-
- @Override
- public ImmutableMapNodeBuilder withNodeIdentifier(final NodeIdentifier withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.Objects.requireNonNull;
-
-import java.util.Set;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-
-final class SchemaAwareImmutableOrderedLeafSetNodeBuilder<T> extends ImmutableUserLeafSetNodeBuilder<T> {
- private final LeafListSchemaNode schema;
-
- SchemaAwareImmutableOrderedLeafSetNodeBuilder(final LeafListSchemaNode schema) {
- this.schema = requireNonNull(schema);
- super.withNodeIdentifier(new NodeIdentifier(schema.getQName()));
- }
-
- SchemaAwareImmutableOrderedLeafSetNodeBuilder(final LeafListSchemaNode schema,
- final ImmutableUserLeafSetNode<T> node) {
- super(node);
- this.schema = requireNonNull(schema);
- // FIXME: Preconditions.checkArgument(schema.getQName().equals(node.getIdentifier()));
- super.withNodeIdentifier(new NodeIdentifier(schema.getQName()));
- }
-
- @Override
- public ImmutableUserLeafSetNodeBuilder<T> withChildValue(final T childValue) {
- // TODO check value type
- return super.withChildValue(childValue);
- }
-
- @Override
- public ImmutableUserLeafSetNodeBuilder<T> withChild(final LeafSetEntryNode<T> child) {
- final NodeWithValue<T> childId = child.getIdentifier();
- final QName childName = childId.getNodeType();
- final QName qname = schema.getQName();
-
- checkArgument(qname.equals(childName), "Incompatible node type, should be: %s, is: %s", qname, childName);
- // TODO check value type using TypeProvider ?
- DataValidationException.checkLegalChild(qname.equals(childName), childId, schema, Set.of(qname));
- return super.withChild(child);
- }
-
- @Override
- public ImmutableUserLeafSetNodeBuilder<T> withNodeIdentifier(final NodeIdentifier withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.impl.schema.builder.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.Set;
-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.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-
-final class SchemaAwareImmutableOrderedMapNodeBuilder extends ImmutableUserMapNodeBuilder {
- private final ListSchemaNode schema;
-
- SchemaAwareImmutableOrderedMapNodeBuilder(final ListSchemaNode schema) {
- this.schema = requireNonNull(schema);
- super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
- }
-
- SchemaAwareImmutableOrderedMapNodeBuilder(final ListSchemaNode schema, final ImmutableUserMapNode node) {
- super(node);
- this.schema = requireNonNull(schema);
- super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
- }
-
- @Override
- public CollectionNodeBuilder<MapEntryNode, UserMapNode> withChild(final MapEntryNode child) {
- final NodeIdentifierWithPredicates childId = child.getIdentifier();
- final QName qname = schema.getQName();
-
- DataValidationException.checkLegalChild(qname.equals(childId.getNodeType()), childId, schema, Set.of(qname));
- return super.withChild(child);
- }
-
- @Override
- public CollectionNodeBuilder<MapEntryNode, UserMapNode> withNodeIdentifier(
- final NodeIdentifier withNodeIdentifier) {
- throw new UnsupportedOperationException("Node identifier created from schema");
- }
-}