X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=code-generator%2Fbinding-data-codec%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fbinding%2Fdata%2Fcodec%2Fimpl%2FLeafNodeCodecContext.java;h=81d9f3a609e75af35da4f76af9aabc51a4db1b0e;hb=8e28ea8d0a0dd7c3bae461121e76fd726af105bb;hp=e8d115c16da8a71fa8fe51bde68d4fa16edbbcb8;hpb=f083501fd61587638c3efb90ae30e1a80ed189d5;p=mdsal.git diff --git a/code-generator/binding-data-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/impl/LeafNodeCodecContext.java b/code-generator/binding-data-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/impl/LeafNodeCodecContext.java index e8d115c16d..81d9f3a609 100644 --- a/code-generator/binding-data-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/impl/LeafNodeCodecContext.java +++ b/code-generator/binding-data-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/impl/LeafNodeCodecContext.java @@ -64,58 +64,57 @@ final class LeafNodeCodecContext extends NodeCodecContext< } @Override - public BindingCodecTreeNode bindingPathArgumentChild(PathArgument arg, - List builder) { - return null; + public BindingCodecTreeNode bindingPathArgumentChild(final PathArgument arg, + final List builder) { + throw new IllegalArgumentException("Leaf does not have children"); } @Override public BindingNormalizedNodeCachingCodec createCachingCodec( - ImmutableCollection> cacheSpecifier) { - return null; + final ImmutableCollection> cacheSpecifier) { + throw new UnsupportedOperationException("Leaves does not support caching codec."); } @Override public Class getBindingClass() { - return null; + throw new UnsupportedOperationException("Leaf does not have DataObject representation"); } @Override - public NormalizedNode serialize(D data) { + public NormalizedNode serialize(final D data) { throw new UnsupportedOperationException("Separete serialization of leaf node is not supported."); } @Override - public void writeAsNormalizedNode(D data, NormalizedNodeStreamWriter writer) { + public void writeAsNormalizedNode(final D data, final NormalizedNodeStreamWriter writer) { throw new UnsupportedOperationException("Separete serialization of leaf node is not supported."); } @Override - public BindingCodecTreeNode streamChild(Class childClass) { - return null; + public BindingCodecTreeNode streamChild(final Class childClass) { + throw new IllegalArgumentException("Leaf does not have children"); } @Override public Optional> possibleStreamChild( - Class childClass) { - return null; + final Class childClass) { + throw new IllegalArgumentException("Leaf does not have children"); } @Override - public BindingCodecTreeNode yangPathArgumentChild( - org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument child) { - return null; + public BindingCodecTreeNode yangPathArgumentChild(final YangInstanceIdentifier.PathArgument child) { + throw new IllegalArgumentException("Leaf does not have children"); } @Override - protected Object deserializeObject(NormalizedNode normalizedNode) { + protected Object deserializeObject(final NormalizedNode normalizedNode) { if (normalizedNode instanceof LeafNode) { return valueCodec.deserialize(normalizedNode.getValue()); } else if(normalizedNode instanceof LeafSetNode) { @SuppressWarnings("unchecked") - Collection> domValues = ((LeafSetNode) normalizedNode).getValue(); - List result = new ArrayList<>(domValues.size()); - for (LeafSetEntryNode valueNode : domValues) { + final Collection> domValues = ((LeafSetNode) normalizedNode).getValue(); + final List result = new ArrayList<>(domValues.size()); + for (final LeafSetEntryNode valueNode : domValues) { result.add(valueCodec.deserialize(valueNode.getValue())); } return result; @@ -124,13 +123,13 @@ final class LeafNodeCodecContext extends NodeCodecContext< } @Override - public InstanceIdentifier.PathArgument deserializePathArgument(YangInstanceIdentifier.PathArgument arg) { + public InstanceIdentifier.PathArgument deserializePathArgument(final YangInstanceIdentifier.PathArgument arg) { Preconditions.checkArgument(getDomPathArgument().equals(arg)); return null; } @Override - public YangInstanceIdentifier.PathArgument serializePathArgument(InstanceIdentifier.PathArgument arg) { + public YangInstanceIdentifier.PathArgument serializePathArgument(final InstanceIdentifier.PathArgument arg) { return getDomPathArgument(); }