@Beta
void writeAsNormalizedNode(T data, NormalizedNodeStreamWriter writer);
+
+ /**
+ * Serializes path argument for current node.
+ *
+ * @param arg Binding Path Argument, may be null if Binding Instance Identifier does not have
+ * representation for current node (e.g. choice or case).
+ * @return Yang Path Argument, may be null if Yang Instance Identifier does not have
+ * representation for current node (e.g. case).
+ * @throws IllegalArgumentException If supplied {@code arg} is not valid.
+ */
+ @Beta
+ @Nullable YangInstanceIdentifier.PathArgument serializePathArgument(@Nullable InstanceIdentifier.PathArgument arg);
+
+ /**
+ * Deserializes path argument for current node.
+ *
+ * @param arg Yang Path Argument, may be null if Yang Instance Identifier does not have
+ * representation for current node (e.g. case).
+ * @return Binding Path Argument, may be null if Binding Instance Identifier does not have
+ * representation for current node (e.g. choice or case).
+ * @throws IllegalArgumentException If supplied {@code arg} is not valid.
+ */
+ @Beta
+ @Nullable InstanceIdentifier.PathArgument deserializePathArgument(@Nullable YangInstanceIdentifier.PathArgument arg);
}
protected Object deserializeObject(NormalizedNode<?, ?> normalizedNode) {
return deserialize(normalizedNode);
}
+
+ @Override
+ public org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument serializePathArgument(
+ PathArgument arg) {
+ Preconditions.checkArgument(arg == null);
+ return null;
+ }
+
+ @Override
+ public PathArgument deserializePathArgument(
+ org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument arg) {
+ Preconditions.checkArgument(arg == null);
+ return null;
+ }
}
\ No newline at end of file
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
return deserialize(normalizedNode);
}
+ @Override
+ public PathArgument deserializePathArgument(YangInstanceIdentifier.PathArgument arg) {
+ Preconditions.checkArgument(getDomPathArgument().equals(arg));
+ return null;
+ }
+
+ @Override
+ public YangInstanceIdentifier.PathArgument serializePathArgument(
+ PathArgument arg) {
+ // FIXME: check for null, since binding container is null.
+ return getDomPathArgument();
+ }
+
}
return byMethod.keySet();
}
+ @Override
+ public InstanceIdentifier.PathArgument deserializePathArgument(YangInstanceIdentifier.PathArgument arg) {
+ Preconditions.checkArgument(getDomPathArgument().equals(arg));
+ return bindingArg();
+ }
+
+ @Override
+ public YangInstanceIdentifier.PathArgument serializePathArgument(InstanceIdentifier.PathArgument arg) {
+ Preconditions.checkArgument(bindingArg().equals(arg));
+ return getDomPathArgument();
+ }
}
NodeIdentifierWithPredicates serialize(final Identifier<?> key) {
return codec.serialize(new IdentifiableItem(getBindingClass(), key));
}
+
+ @Override
+ public YangInstanceIdentifier.PathArgument serializePathArgument(InstanceIdentifier.PathArgument arg) {
+ if(arg instanceof IdentifiableItem) {
+ return codec.serialize((IdentifiableItem<?,?>) arg);
+ }
+ return super.serializePathArgument(arg);
+ }
+
+ @Override
+ public InstanceIdentifier.PathArgument deserializePathArgument(YangInstanceIdentifier.PathArgument arg) {
+ if(arg instanceof NodeIdentifierWithPredicates) {
+ return codec.deserialize((NodeIdentifierWithPredicates) arg);
+ }
+ return super.deserializePathArgument(arg);
+ }
+
+
}
package org.opendaylight.yangtools.binding.data.codec.impl;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableCollection;
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeCachingCodec;
import org.opendaylight.yangtools.concepts.Codec;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
return null;
}
+ @Override
+ public InstanceIdentifier.PathArgument deserializePathArgument(YangInstanceIdentifier.PathArgument arg) {
+ Preconditions.checkArgument(getDomPathArgument().equals(arg));
+ return null;
+ }
+
+ @Override
+ public YangInstanceIdentifier.PathArgument serializePathArgument(InstanceIdentifier.PathArgument arg) {
+ return getDomPathArgument();
+ }
+
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.DataRoot;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
throw new UnsupportedOperationException("Unable to deserialize root");
}
+ @Override
+ public InstanceIdentifier.PathArgument deserializePathArgument(YangInstanceIdentifier.PathArgument arg) {
+ Preconditions.checkArgument(arg == null);
+ return null;
+ }
+
+ @Override
+ public YangInstanceIdentifier.PathArgument serializePathArgument(InstanceIdentifier.PathArgument arg) {
+ Preconditions.checkArgument(arg == null);
+ return null;
+ }
+
}
\ No newline at end of file