bindingArguments.add(((DataContainerCodecContext<?, ?>) nextNode).getBindingPathArgument(domArg));
}
currentNode = nextNode;
- } else if (nextNode instanceof LeafNodeCodecContext) {
+ } else if (nextNode instanceof ValueNodeCodecContext) {
LOG.debug("Instance identifier referencing a leaf is not representable ({})", dom);
return null;
}
}
@Override
- public ImmutableMap<String, LeafNodeCodecContext> getLeafNodes(final Class<?> parentClass,
+ public ImmutableMap<String, ValueNodeCodecContext> getLeafNodes(final Class<?> parentClass,
final DataNodeContainer childSchema) {
final Map<String, DataSchemaNode> getterToLeafSchema = new HashMap<>();
for (final DataSchemaNode leaf : childSchema.getChildNodes()) {
return getLeafNodesUsingReflection(parentClass, getterToLeafSchema);
}
- private ImmutableMap<String, LeafNodeCodecContext> getLeafNodesUsingReflection(final Class<?> parentClass,
+ private ImmutableMap<String, ValueNodeCodecContext> getLeafNodesUsingReflection(final Class<?> parentClass,
final Map<String, DataSchemaNode> getterToLeafSchema) {
- final Map<String, LeafNodeCodecContext> leaves = new HashMap<>();
+ final Map<String, ValueNodeCodecContext> leaves = new HashMap<>();
for (final Method method : parentClass.getMethods()) {
if (method.getParameterCount() == 0) {
final DataSchemaNode schema = getterToLeafSchema.get(method.getName());
}
final Codec<Object, Object> codec = getCodec(valueType, typedSchema.getType());
- final LeafNodeCodecContext leafNode = new LeafNodeCodecContext(typedSchema, codec, method,
+ final ValueNodeCodecContext leafNode = new ValueNodeCodecContext(typedSchema, codec, method,
context.getSchemaContext());
leaves.put(schema.getQName().getLocalName(), leafNode);
}
final Class<Identifier<?>> identifier = optIdentifier.get();
final Map<QName, ValueContext> valueCtx = new HashMap<>();
- for (final LeafNodeCodecContext leaf : getLeafNodes(identifier, schema).values()) {
+ for (final ValueNodeCodecContext leaf : getLeafNodes(identifier, schema).values()) {
final QName name = leaf.getDomPathArgument().getNodeType();
valueCtx.put(name, new ValueContext(identifier, leaf));
}
Preconditions.checkArgument(current() instanceof DataObjectCodecContext);
DataObjectCodecContext<?,?> currentCasted = (DataObjectCodecContext<?,?>) current();
- LeafNodeCodecContext leafContext = currentCasted.getLeafChild(localName);
+ ValueNodeCodecContext leafContext = currentCasted.getLeafChild(localName);
NodeIdentifier domArg = (NodeIdentifier) leafContext.getDomPathArgument();
Object domValue = leafContext.getValueCodec().serialize(value);
@Override
public void leafSetEntryNode(final Object value) throws IOException {
- final LeafNodeCodecContext ctx = (LeafNodeCodecContext) current();
+ final ValueNodeCodecContext ctx = (ValueNodeCodecContext) current();
final Object domValue = ctx.getValueCodec().serialize(value);
delegate.startLeafSetEntryNode(new NodeWithValue<>(ctx.getSchema().getQName(), domValue));
delegate.scalarValue(domValue);
private static final Augmentations EMPTY_AUGMENTATIONS = new Augmentations(ImmutableMap.of(), ImmutableMap.of());
private static final Method[] EMPTY_METHODS = new Method[0];
- private final ImmutableMap<String, LeafNodeCodecContext> leafChild;
+ private final ImmutableMap<String, ValueNodeCodecContext> leafChild;
private final ImmutableMap<YangInstanceIdentifier.PathArgument, NodeContextSupplier> byYang;
private final ImmutableMap<String, NodeContextSupplier> byMethod;
private final ImmutableMap<String, String> nonnullToGetter;
final Map<Class<?>, DataContainerCodecPrototype<?>> byBindingArgClassBuilder = new HashMap<>();
// Adds leaves to mapping
- for (final LeafNodeCodecContext leaf : leafChild.values()) {
+ for (final ValueNodeCodecContext leaf : leafChild.values()) {
tmpMethodToSupplier.put(leaf.getGetter(), leaf);
byYangBuilder.put(leaf.getDomPathArgument(), leaf);
}
return childNonNull(childSupplier, arg, "Argument %s is not valid child of %s", arg, getSchema()).get();
}
- protected final LeafNodeCodecContext getLeafChild(final String name) {
- final LeafNodeCodecContext value = leafChild.get(name);
+ protected final ValueNodeCodecContext getLeafChild(final String name) {
+ final ValueNodeCodecContext value = leafChild.get(name);
return IncorrectNestingException.checkNonNull(value, "Leaf %s is not valid for %s", name, getBindingClass());
}
* <p>
* Two core subtypes of codec context are available:
* <ul>
- * <li>{@link LeafNodeCodecContext} - Context for nodes, which does not contain any nested YANG modeled substructures.
+ * <li>{@link ValueNodeCodecContext} - Context for nodes, which does not contain any nested YANG modeled substructures.
* </li>
* <li>{@link DataObjectCodecContext} - Context for nodes, which does contain nested YANG modeled substructures. This
* context nodes contains context for children nodes.</li>
* @param schema Instantiated schema of binding type.
* @return Map of local name to leaf node context.
*/
- ImmutableMap<String, LeafNodeCodecContext> getLeafNodes(Class<?> type, DataNodeContainer schema);
+ ImmutableMap<String, ValueNodeCodecContext> getLeafNodes(Class<?> type, DataNodeContainer schema);
/**
* Returns Path argument codec for list item.
* A cache of NormalizedNodes corresponding to a particular TypeObject instantiation.
*/
final class TypeObjectNormalizedNodeCache
- extends AbstractBindingNormalizedNodeCache<TypeObject, LeafNodeCodecContext> {
- TypeObjectNormalizedNodeCache(final LeafNodeCodecContext rootContext) {
+ extends AbstractBindingNormalizedNodeCache<TypeObject, ValueNodeCodecContext> {
+ TypeObjectNormalizedNodeCache(final ValueNodeCodecContext rootContext) {
super(rootContext);
}
private final Class<?> identifier;
private final String getterName;
- ValueContext(final Class<?> identifier, final LeafNodeCodecContext leaf) {
+ ValueContext(final Class<?> identifier, final ValueNodeCodecContext leaf) {
getterName = leaf.getGetter().getName();
try {
getter = MethodHandles.publicLookup().unreflect(identifier.getMethod(getterName)).asType(OBJECT_METHOD);
import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
+/**
+ * Abstract base class for atomic nodes. These are nodes which are not decomposed in the Binding Specification, such
+ * as LeafNodes and LeafSetNodes.
+ */
// FIXME: MDSAL-436: this class should be specialized for Leaf and LeafSet
-final class LeafNodeCodecContext extends NodeCodecContext implements NodeContextSupplier {
+final class ValueNodeCodecContext extends NodeCodecContext implements NodeContextSupplier {
private final NodeIdentifier yangIdentifier;
private final Codec<Object, Object> valueCodec;
private final Method getter;
private final TypedDataSchemaNode schema;
private final Object defaultObject;
- LeafNodeCodecContext(final TypedDataSchemaNode schema, final Codec<Object, Object> codec, final Method getter,
- final SchemaContext schemaContext) {
+ ValueNodeCodecContext(final TypedDataSchemaNode schema, final Codec<Object, Object> codec,
+ final Method getter, final SchemaContext schemaContext) {
this.yangIdentifier = NodeIdentifier.create(schema.getQName());
this.valueCodec = requireNonNull(codec);
this.getter = getter;