- public DataContainerCodecContext<?,?> bindingPathArgumentChild(final InstanceIdentifier.PathArgument arg,
- final List<YangInstanceIdentifier.PathArgument> builder) {
-
- final Class<? extends DataObject> argType = arg.getType();
- DataContainerCodecPrototype<?> ctxProto = byBindingArgClass.get(argType);
- if (ctxProto == null && Augmentation.class.isAssignableFrom(argType)) {
- ctxProto = augmentationByClass(argType);
- }
- final DataContainerCodecContext<?, ?> context = childNonNull(ctxProto, argType,
- "Class %s is not valid child of %s", argType, getBindingClass()).get();
- if (context instanceof ChoiceNodeCodecContext) {
- final ChoiceNodeCodecContext<?> choice = (ChoiceNodeCodecContext<?>) context;
- choice.addYangPathArgument(arg, builder);
-
- final Optional<? extends Class<? extends DataObject>> caseType = arg.getCaseType();
- final Class<? extends DataObject> type = arg.getType();
- final DataContainerCodecContext<?, ?> caze;
- if (caseType.isPresent()) {
- // Non-ambiguous addressing this should not pose any problems
- caze = choice.streamChild(caseType.get());
- } else {
- caze = choice.getCaseByChildClass(type);
- }
-
- caze.addYangPathArgument(arg, builder);
- return caze.bindingPathArgumentChild(arg, builder);
- }
- context.addYangPathArgument(arg, builder);
- return context;
- }
-
- @Override
- public NodeCodecContext yangPathArgumentChild(final YangInstanceIdentifier.PathArgument arg) {
- final NodeContextSupplier childSupplier;
- if (arg instanceof NodeIdentifierWithPredicates) {
- childSupplier = byYang.get(new NodeIdentifier(arg.getNodeType()));
- } else if (arg instanceof AugmentationIdentifier) {
- childSupplier = yangAugmentationChild((AugmentationIdentifier) arg);
- } else {
- childSupplier = byYang.get(arg);
- }
-
- return childNonNull(childSupplier, arg, "Argument %s is not valid child of %s", arg, getSchema()).get();
- }
-
- 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());
- }
-
- private DataContainerCodecPrototype<?> loadChildPrototype(final Class<?> childClass) {
- final DataSchemaNode origDef = factory().getRuntimeContext().getSchemaDefinition(childClass);
- // Direct instantiation or use in same module in which grouping
- // was defined.
- DataSchemaNode sameName;
- try {
- sameName = getSchema().getDataChildByName(origDef.getQName());
- } catch (final IllegalArgumentException e) {
- sameName = null;
- }
- final DataSchemaNode childSchema;
- if (sameName != null) {
- // Exactly same schema node
- if (origDef.equals(sameName)) {
- childSchema = sameName;
- // We check if instantiated node was added via uses
- // statement and is instantiation of same grouping
- } else if (origDef.equals(SchemaNodeUtils.getRootOriginalIfPossible(sameName))) {
- childSchema = sameName;
- } else {
- // Node has same name, but clearly is different
- childSchema = null;