X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=model%2Fyang-model-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Fapi%2FChoiceSchemaNode.java;fp=model%2Fyang-model-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Fapi%2FChoiceSchemaNode.java;h=12f21b88aa2bf2acb6d572f5fe7d4943c149187f;hb=18a9431c0d7c31f59647c9d7092bd3790350c11d;hp=3ad06afe884bbfc4e4b260d0e1fb57971e6a8f38;hpb=b0297ee9a557ff67405ba35ac2169ab5f5b4b6b0;p=yangtools.git diff --git a/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ChoiceSchemaNode.java b/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ChoiceSchemaNode.java index 3ad06afe88..12f21b88aa 100644 --- a/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ChoiceSchemaNode.java +++ b/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ChoiceSchemaNode.java @@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement; /** * A ChoiceSchemaNode defines a set of alternatives. It consists of a number of branches defined as - * ChoiceCaseSchemaNode objects. + * {@link CaseSchemaNode} objects. */ public interface ChoiceSchemaNode extends DataSchemaNode, AugmentationTarget, MandatoryAware, EffectiveStatementEquivalent { @@ -28,8 +28,8 @@ public interface ChoiceSchemaNode extends DataSchemaNode, AugmentationTarget, Ma * Returns cases of choice, keyed by their {@link SchemaNode#getQName()}. Returned map does not contain null keys * nor values. * - * @return set of ChoiceCaseNode objects defined in this node which represents set of arguments of the YANG - * case substatement of the choice statement. + * @return set of {@link CaseSchemaNode} objects defined in this node which represents set of arguments of the YANG + * {@code case} substatement of the {@code choice} statement. */ Collection getCases(); @@ -39,7 +39,7 @@ public interface ChoiceSchemaNode extends DataSchemaNode, AugmentationTarget, Ma * @param qname * QName of sought Choice Case Node * @return child case node of this Choice if child with given name is present, empty otherwise. - * @throws NullPointerException if qname is null + * @throws NullPointerException {@code qname} is {@code null} */ default Optional findCaseNode(final QName qname) { requireNonNull(qname); @@ -49,36 +49,35 @@ public interface ChoiceSchemaNode extends DataSchemaNode, AugmentationTarget, Ma /** * Returns the concrete cases according to specified name, disregarding their namespace. * - * @param localname - * local name of sought child as String + * @param localName local name of sought child as String * @return child case nodes matching specified local name, empty list if no match is found. - * @throws NullPointerException if localname is null + * @throws NullPointerException if {@code localName} is {@code null} */ @Beta - default List findCaseNodes(final String localname) { - return getCases().stream().filter(node -> localname.equals(node.getQName().getLocalName())) - .collect(ImmutableList.toImmutableList()); + default List findCaseNodes(final String localName) { + requireNonNull(localName); + return getCases().stream() + .filter(node -> localName.equals(node.getQName().getLocalName())) + .collect(ImmutableList.toImmutableList()); } /** * Find a specific data schema child, if present. This method searches among its {@link CaseSchemaNode}s, * potentially recursing to nested choices. * - * @param qname - * QName of sought data schema node + * @param qname QName of sought data schema node * @return Matching node, or empty if no match is found - * @throws NullPointerException if qname is null + * @throws NullPointerException if {@code qname} is {@code null} */ @Beta default Optional findDataSchemaChild(final QName qname) { requireNonNull(qname); - for (CaseSchemaNode caseNode : getCases()) { - final Optional child = caseNode.findDataChildByName(qname); - if (child.isPresent()) { - return child; + for (var caseNode : getCases()) { + final var child = caseNode.dataChildByName(qname); + if (child != null) { + return Optional.of(child); } } - return Optional.empty(); }