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%2FImmutableUnkeyedListNodeBuilder.java;fp=data%2Fyang-data-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fimpl%2Fschema%2Fbuilder%2Fimpl%2FImmutableUnkeyedListNodeBuilder.java;h=38fcd3395bbcd42fc21f6e9eaa09b87b9432468d;hb=0c68ef30eccfd908aa0095ac74b6d803b7bfb33e;hp=dfb2a49ca51c857340177a30ca920a485ed71551;hpb=9c570d53e902018a42222ed344d0e3336113a346;p=yangtools.git diff --git a/data/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableUnkeyedListNodeBuilder.java b/data/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableUnkeyedListNodeBuilder.java index dfb2a49ca5..38fcd3395b 100644 --- a/data/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableUnkeyedListNodeBuilder.java +++ b/data/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableUnkeyedListNodeBuilder.java @@ -28,16 +28,16 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder(); - this.dirty = false; + value = new LinkedList<>(); + dirty = false; } protected ImmutableUnkeyedListNodeBuilder(final ImmutableUnkeyedListNode node) { - this.nodeIdentifier = node.getIdentifier(); + nodeIdentifier = node.getIdentifier(); // FIXME: clean this up, notably reuse unmodified lists - this.value = new LinkedList<>(); + value = new LinkedList<>(); Iterables.addAll(value, node.body()); - this.dirty = true; + dirty = true; } public static CollectionNodeBuilder create() { @@ -50,11 +50,10 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder create( final UnkeyedListNode node) { - if (!(node instanceof ImmutableUnkeyedListNode)) { - throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass())); + if (!(node instanceof ImmutableUnkeyedListNode immutableNode)) { + throw new UnsupportedOperationException("Cannot initialize from class " + node.getClass()); } - - return new ImmutableUnkeyedListNodeBuilder((ImmutableUnkeyedListNode) node); + return new ImmutableUnkeyedListNodeBuilder(immutableNode); } private void checkDirty() { @@ -67,7 +66,7 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder withChild(final UnkeyedListEntryNode child) { checkDirty(); - this.value.add(child); + value.add(child); return this; } @@ -92,7 +91,7 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder withNodeIdentifier( final NodeIdentifier withNodeIdentifier) { - this.nodeIdentifier = withNodeIdentifier; + nodeIdentifier = withNodeIdentifier; return this; } @@ -189,8 +188,8 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder otherChildren; - if (other instanceof ImmutableUnkeyedListNode) { - otherChildren = ((ImmutableUnkeyedListNode) other).children; + if (other instanceof ImmutableUnkeyedListNode immutableOther) { + otherChildren = immutableOther.children; } else { otherChildren = other.body(); }