- private static final Optional<DataSchemaNode> findChildSchemaNode(final DataNodeContainer parent,final QName child) {
- DataSchemaNode potential = parent.getDataChildByName(child);
- if (potential == null) {
- Iterable<ChoiceSchemaNode> choices = FluentIterable.from(parent.getChildNodes()).filter(ChoiceSchemaNode.class);
- potential = findChoice(choices, child);
- }
- return Optional.fromNullable(potential);
- }
-
- private static DataNormalizationOperation<?> fromSchemaAndQNameChecked(final DataNodeContainer schema,
- final QName child) throws DataNormalizationException {
-
- Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child);
- if (!potential.isPresent()) {
- throw new DataNormalizationException(String.format("Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema,schema.getChildNodes()));
- }
-
- DataSchemaNode result = potential.get();
- // We try to look up if this node was added by augmentation
- if ((schema instanceof DataSchemaNode) && result.isAugmenting()) {
- return fromAugmentation(schema, (AugmentationTarget) schema, result);
- }
- return fromDataSchemaNode(result);
+ private static @Nullable DataSchemaNode findChildSchemaNode(final DataNodeContainer parent, final QName child) {
+ final DataSchemaNode potential = parent.getDataChildByName(child);
+ return potential != null ? potential : findChoice(parent, child);