- private static DataNormalizationOperation<?> fromSchemaAndQNameChecked(final DataNodeContainer schema,
- final QName child) throws DataNormalizationException {
-
- final 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()));
- }
-
- final 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 ChoiceSchemaNode findChoice(final Iterable<ChoiceSchemaNode> choices, final QName child) {
- ChoiceSchemaNode foundChoice = null;
- choiceLoop: for (final ChoiceSchemaNode choice : choices) {
+ private static @Nullable ChoiceSchemaNode findChoice(final DataNodeContainer parent, final QName child) {
+ for (final ChoiceSchemaNode choice : Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class)) {