- final var argType = arg.getType();
- final var context = childNonNull(pathChildPrototype(argType), argType,
- "Class %s is not valid child of %s", argType, getBindingClass())
- .get();
- if (context instanceof ChoiceCodecContext<?> choice) {
- choice.addYangPathArgument(arg, builder);
-
- final var caseType = arg.getCaseType();
- final var type = arg.getType();
- final DataContainerCodecContext<?, ?> caze;
- if (caseType.isPresent()) {
- // Non-ambiguous addressing this should not pose any problems
- caze = choice.getStreamChild(caseType.orElseThrow());
- } else {
- caze = choice.getCaseByChildClass(type);
- }
-
- caze.addYangPathArgument(arg, builder);
- return caze.bindingPathArgumentChild(arg, builder);
+ final var type = step.type();
+ final var context = childNonNull(pathChildPrototype(type), type,
+ "Class %s is not valid child of %s", type, getBindingClass())
+ .getCodecContext();
+ context.addYangPathArgument(step, builder);
+ if (context instanceof CommonDataObjectCodecContext<?, ?> dataObject) {
+ return dataObject;
+ } else if (context instanceof ChoiceCodecContext<?> choice) {
+ return choice.bindingPathArgumentChild(step, builder);
+ } else {
+ throw new IllegalStateException("Unhandled context " + context);