-
- @Override
- protected YangInstanceIdentifier.PathArgument getDomPathArgument() {
- return yangIdentifier;
- }
-
- protected Codec<Object, Object> getValueCodec() {
- return valueCodec;
- }
-
- @Override
- public D deserialize(final NormalizedNode<?, ?> normalizedNode) {
- throw new UnsupportedOperationException("Leaf can not be deserialized to DataObject");
- }
-
- @Override
- public NodeCodecContext<?> get() {
- return this;
- }
-
- Method getGetter() {
- return getter;
- }
-
- @Override
- public BindingCodecTreeNode<?> bindingPathArgumentChild(final PathArgument arg,
- final List<YangInstanceIdentifier.PathArgument> builder) {
- throw new IllegalArgumentException("Leaf does not have children");
- }
-
- @Override
- public BindingNormalizedNodeCachingCodec<D> createCachingCodec(
- final ImmutableCollection<Class<? extends DataObject>> cacheSpecifier) {
- throw new UnsupportedOperationException("Leaves does not support caching codec.");
- }
-
- @Override
- public Class<D> getBindingClass() {
- throw new UnsupportedOperationException("Leaf does not have DataObject representation");
- }
-
- @Override
- public NormalizedNode<?, ?> serialize(final D data) {
- throw new UnsupportedOperationException("Separete serialization of leaf node is not supported.");
- }
-
- @Override
- public void writeAsNormalizedNode(final D data, final NormalizedNodeStreamWriter writer) {
- throw new UnsupportedOperationException("Separete serialization of leaf node is not supported.");
- }
-
- @Override
- public <E extends DataObject> BindingCodecTreeNode<E> streamChild(final Class<E> childClass) {
- throw new IllegalArgumentException("Leaf does not have children");
- }
-
- @Override
- public <E extends DataObject> Optional<? extends BindingCodecTreeNode<E>> possibleStreamChild(
- final Class<E> childClass) {
- throw new IllegalArgumentException("Leaf does not have children");
- }
-
- @Override
- public BindingCodecTreeNode<?> yangPathArgumentChild(final YangInstanceIdentifier.PathArgument child) {
- throw new IllegalArgumentException("Leaf does not have children");
- }
-
- @Override
- protected Object deserializeObject(final NormalizedNode<?, ?> normalizedNode) {
- if (normalizedNode instanceof LeafNode<?>) {
- return valueCodec.deserialize(normalizedNode.getValue());
- }
- if (normalizedNode instanceof LeafSetNode<?>) {
- @SuppressWarnings("unchecked")
- final Collection<LeafSetEntryNode<Object>> domValues = ((LeafSetNode<Object>) normalizedNode).getValue();
- final List<Object> result = new ArrayList<>(domValues.size());
- for (final LeafSetEntryNode<Object> valueNode : domValues) {
- result.add(valueCodec.deserialize(valueNode.getValue()));
- }
- return result;
- }
- return null;
- }
-
- @Override
- public InstanceIdentifier.PathArgument deserializePathArgument(final YangInstanceIdentifier.PathArgument arg) {
- checkArgument(getDomPathArgument().equals(arg));
- return null;
- }
-
- @Override
- public YangInstanceIdentifier.PathArgument serializePathArgument(final InstanceIdentifier.PathArgument arg) {
- return getDomPathArgument();
- }
-
- @Override
- public DataSchemaNode getSchema() {
- return schema;
- }
-
- @Override
- public ChildAddressabilitySummary getChildAddressabilitySummary() {
- return ChildAddressabilitySummary.UNADDRESSABLE;
- }
-
- @Override
- Object defaultObject() {
- return defaultObject;
- }