X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=data%2Fyang-data-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fimpl%2Fschema%2Fbuilder%2Fimpl%2FImmutableAugmentationNodeBuilder.java;fp=data%2Fyang-data-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fimpl%2Fschema%2Fbuilder%2Fimpl%2FImmutableAugmentationNodeBuilder.java;h=0000000000000000000000000000000000000000;hb=3d2579db1ac441dadf84e0ff7dab904832a87bf2;hp=76fb1d671643d704224565edc402a2070bb2f6ea;hpb=9a51cd8e2646e02c1c44c7de7c375e29dfe842f9;p=yangtools.git diff --git a/data/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAugmentationNodeBuilder.java b/data/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAugmentationNodeBuilder.java deleted file mode 100644 index 76fb1d6716..0000000000 --- a/data/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAugmentationNodeBuilder.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 java.util.Map; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -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.DataValidationException; -import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode; - -public class ImmutableAugmentationNodeBuilder - extends AbstractImmutableDataContainerNodeBuilder { - - protected ImmutableAugmentationNodeBuilder() { - } - - protected ImmutableAugmentationNodeBuilder(final int sizeHint) { - super(sizeHint); - } - - ImmutableAugmentationNodeBuilder(final ImmutableAugmentationNode node) { - super(node); - } - - public static @NonNull DataContainerNodeBuilder create() { - return new ImmutableAugmentationNodeBuilder(); - } - - public static @NonNull DataContainerNodeBuilder create( - final int sizeHint) { - return new ImmutableAugmentationNodeBuilder(sizeHint); - } - - public static @NonNull DataContainerNodeBuilder create( - final AugmentationNode node) { - if (!(node instanceof ImmutableAugmentationNode immutableNode)) { - throw new UnsupportedOperationException("Cannot initialize from class " + node.getClass()); - } - return new ImmutableAugmentationNodeBuilder(immutableNode); - } - - @Override - public DataContainerNodeBuilder withChild( - final DataContainerChild child) { - // Check nested augments - if (child instanceof AugmentationNode aug) { - final var myId = getNodeIdentifier(); - throw new DataValidationException(String.format( - "Unable to add: %s, as a child for: %s, Nested augmentations are not permitted", aug.getIdentifier(), - myId == null ? this : myId)); - } - - return super.withChild(child); - } - - @Override - public DataContainerNodeBuilder withoutChild(final PathArgument key) { - return super.withoutChild(key); - } - - @Override - public AugmentationNode build() { - return new ImmutableAugmentationNode(getNodeIdentifier(), buildValue()); - } - - private static final class ImmutableAugmentationNode - extends AbstractImmutableDataContainerNode - implements AugmentationNode { - - ImmutableAugmentationNode(final AugmentationIdentifier nodeIdentifier, - final Map children) { - super(children, nodeIdentifier); - } - - @Override - protected Class implementedType() { - return AugmentationNode.class; - } - } -}