X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fimpl%2Fschema%2Fbuilder%2Fimpl%2FImmutableMapNodeSchemaAwareBuilder.java;h=412dbfe41bbbfea9a32ee66f5d35596df636449f;hb=9d74a74a9d46ff8c6878bc7d76994782d938cddc;hp=fc976ea432f6779196a94873079e4c242194ad30;hpb=3b083642b160edb491ff2f1ee5c052586d0f650a;p=yangtools.git diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableMapNodeSchemaAwareBuilder.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableMapNodeSchemaAwareBuilder.java index fc976ea432..412dbfe41b 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableMapNodeSchemaAwareBuilder.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableMapNodeSchemaAwareBuilder.java @@ -7,34 +7,38 @@ */ package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import static java.util.Objects.requireNonNull; + +import java.util.Collections; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import com.google.common.base.Preconditions; - +@Deprecated(since = "6.0.7", forRemoval = true) public class ImmutableMapNodeSchemaAwareBuilder extends ImmutableMapNodeBuilder { - private final ListSchemaNode schema; protected ImmutableMapNodeSchemaAwareBuilder(final ListSchemaNode schema) { - this.schema = Preconditions.checkNotNull(schema); - super.withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(schema.getQName())); + this.schema = requireNonNull(schema); + super.withNodeIdentifier(NodeIdentifier.create(schema.getQName())); } protected ImmutableMapNodeSchemaAwareBuilder(final ListSchemaNode schema, final ImmutableMapNode node) { super(node); - this.schema = Preconditions.checkNotNull(schema); - super.withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(schema.getQName())); + this.schema = requireNonNull(schema); + super.withNodeIdentifier(NodeIdentifier.create(schema.getQName())); } - public static CollectionNodeBuilder create(final ListSchemaNode schema) { + public static @NonNull CollectionNodeBuilder create(final ListSchemaNode schema) { return new ImmutableMapNodeSchemaAwareBuilder(schema); } - public static CollectionNodeBuilder create(final ListSchemaNode schema, final MapNode node) { + public static @NonNull CollectionNodeBuilder create(final ListSchemaNode schema, + final MapNode node) { if (!(node instanceof ImmutableMapNode)) { throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass())); } @@ -44,13 +48,13 @@ public class ImmutableMapNodeSchemaAwareBuilder extends ImmutableMapNodeBuilder @Override public CollectionNodeBuilder withChild(final MapEntryNode child) { - Preconditions.checkArgument(schema.getQName().equals(child.getNodeType()), - "Incompatible node type, should be: %s, is: %s", schema.getQName(), child.getNodeType()); + DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), + schema, Collections.singleton(schema.getQName())); return super.withChild(child); } @Override - public CollectionNodeBuilder withNodeIdentifier(final InstanceIdentifier.NodeIdentifier nodeIdentifier) { + public CollectionNodeBuilder withNodeIdentifier(final NodeIdentifier withNodeIdentifier) { throw new UnsupportedOperationException("Node identifier created from schema"); } }