protected ChoiceNodeNormalization(final ChoiceSchemaNode schema) { super(new NodeIdentifier(schema.getQName())); final ImmutableMap.Builder<PathArgument, InstanceIdToNodes<?>> byArgBuilder = ImmutableMap.builder(); for (final ChoiceCaseNode caze : schema.getCases()) { for (final DataSchemaNode cazeChild : caze.getChildNodes()) { final InstanceIdToNodes<?> childOp = fromDataSchemaNode(cazeChild); byArgBuilder.put(childOp.getIdentifier(), childOp); } } byArg = byArgBuilder.build(); }
@Override @SuppressWarnings("unchecked") public final NormalizedNode<?, ?> create( final YangInstanceIdentifier instanceId, final Optional<NormalizedNode<?, ?>> lastChild, final Optional<Map.Entry<QName, ModifyAction>> operation) { checkNotNull(instanceId); final Iterator<PathArgument> iterator = instanceId.getPathArguments().iterator(); final PathArgument legacyData = iterator.next(); if (!isMixin() && getIdentifier().getNodeType() != null) { checkArgument( getIdentifier().getNodeType().equals(legacyData.getNodeType()), "Node QName must be %s was %s", getIdentifier().getNodeType(), legacyData.getNodeType()); } final NormalizedNodeContainerBuilder builder = createBuilder(legacyData); if (iterator.hasNext()) { final PathArgument childPath = iterator.next(); final InstanceIdToNodes<?> childOp = getChildOperation(childPath); final YangInstanceIdentifier childId = YangInstanceIdentifier.create(Iterables.skip(instanceId.getPathArguments(), 1)); builder.addChild(childOp.create(childId, lastChild, operation)); } else { if (lastChild.isPresent()) { builder.withValue(Lists.newArrayList((Collection<?>) lastChild.get().getValue())); } if (operation.isPresent()) { Preconditions.checkArgument(builder instanceof AttributesBuilder<?>); addModifyOpIfPresent(operation, ((AttributesBuilder<?>) builder)); } } return builder.build(); }
private InstanceIdToNodes<?> register(final InstanceIdToNodes<?> potential) { if (potential != null) { byArg.put(potential.getIdentifier(), potential); } return potential; }