import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
-import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
import org.opendaylight.yangtools.yang.model.api.ActionNodeContainer;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
}
} else if (dsn instanceof ChoiceSchemaNode) {
for (final CaseSchemaNode choiceCase : ((ChoiceSchemaNode) dsn).getCases().values()) {
-
- final DataSchemaNode dataChildByName = choiceCase.getDataChildByName(qname);
- if (dataChildByName != null) {
- return Optional.of(dataChildByName);
+ final Optional<DataSchemaNode> dataChildByName = choiceCase.findDataChildByName(qname);
+ if (dataChildByName.isPresent()) {
+ return dataChildByName;
}
final Optional<DataSchemaNode> foundDsn = findFirstSchema(qname, choiceCase.getChildNodes());
if (foundDsn.isPresent()) {
public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname) {
// Try to find child schema node directly, but use a fallback that compares QNames without revisions
// and auto-expands choices
- final DataSchemaNode dataChildByName = schema.getDataChildByName(qname);
- return dataChildByName == null ? findSchemaForChild(schema, qname, schema.getChildNodes()) : dataChildByName;
+ final Optional<DataSchemaNode> dataChildByName = schema.findDataChildByName(qname);
+ return dataChildByName.isPresent() ? dataChildByName.get()
+ : findSchemaForChild(schema, qname, schema.getChildNodes());
}
public static @Nullable DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname,
}
for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) schema).getAvailableAugmentations()) {
- if (augmentation.getDataChildByName(childSchema.getQName()) != null) {
+ if (augmentation.findDataChildByName(childSchema.getQName()).isPresent()) {
return true;
}
}
public static Set<DataSchemaNode> getRealSchemasForAugment(final AugmentationTarget targetSchema,
final AugmentationSchemaNode augmentSchema) {
if (!targetSchema.getAvailableAugmentations().contains(augmentSchema)) {
- return Collections.emptySet();
+ return ImmutableSet.of();
}
if (targetSchema instanceof DataNodeContainer) {
return getRealSchemasForAugment((DataNodeContainer)targetSchema, augmentSchema);
if (child instanceof AugmentationNode
&& belongsToCaseAugment(choiceCaseNode, (AugmentationIdentifier) child.getIdentifier())) {
return Optional.of(choiceCaseNode);
- } else if (choiceCaseNode.getDataChildByName(child.getNodeType()) != null) {
+ } else if (choiceCaseNode.findDataChildByName(child.getNodeType()).isPresent()) {
return Optional.of(choiceCaseNode);
}
}
}
for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) {
- final DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName());
- if (childInAugmentation != null) {
+ final Optional<DataSchemaNode> childInAugmentation = augmentation.findDataChildByName(child.getQName());
+ if (childInAugmentation.isPresent()) {
return augmentation;
}
}
return null;
}
- /**
- * Create AugmentationIdentifier from an AugmentationSchemaNode.
- *
- * @param schema Augmentation schema
- * @return AugmentationIdentifier for the schema
- * @throws NullPointerException if {@code schema} is null
- * @deprecated Use {@link DataSchemaContextNode#augmentationIdentifierFrom(AugmentationSchemaNode)} instead.
- */
- @Deprecated
- public static AugmentationIdentifier getNodeIdentifierForAugmentation(final AugmentationSchemaNode schema) {
- return DataSchemaContextNode.augmentationIdentifierFrom(schema);
- }
-
/**
* Finds schema node for given path in schema context. This method performs
* lookup in the namespace of all leafs, leaf-lists, lists, containers,