import com.google.common.collect.Collections2;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
private SchemaUtils() {
}
- public static final Optional<DataSchemaNode> findFirstSchema(final QName qname, final Set<DataSchemaNode> dataSchemaNode) {
- if (dataSchemaNode != null && !dataSchemaNode.isEmpty() && qname != null) {
+ public static final Optional<DataSchemaNode> findFirstSchema(final QName qname, final Iterable<DataSchemaNode> dataSchemaNode) {
+ if (dataSchemaNode != null && qname != null) {
for (DataSchemaNode dsn : dataSchemaNode) {
if (qname.isEqualWithoutRevision(dsn.getQName())) {
return Optional.<DataSchemaNode> of(dsn);
}
public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname) {
- Set<DataSchemaNode> childNodes = schema.getChildNodes();
- return findSchemaForChild(schema, qname, childNodes);
+ return findSchemaForChild(schema, qname, schema.getChildNodes());
}
- public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname, final Set<DataSchemaNode> childNodes) {
+ public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname, final Iterable<DataSchemaNode> childNodes) {
Optional<DataSchemaNode> childSchema = findFirstSchema(qname, childNodes);
Preconditions.checkState(childSchema.isPresent(),
"Unknown child(ren) node(s) detected, identified by: %s, in: %s", qname, schema);
* @return Map with all child nodes, to their most top augmentation
*/
public static Map<QName, ChoiceNode> mapChildElementsFromChoices(final DataNodeContainer schema) {
- Set<DataSchemaNode> childNodes = schema.getChildNodes();
-
- return mapChildElementsFromChoices(schema, childNodes);
+ return mapChildElementsFromChoices(schema, schema.getChildNodes());
}
- private static Map<QName, ChoiceNode> mapChildElementsFromChoices(final DataNodeContainer schema, final Set<DataSchemaNode> childNodes) {
+ private static Map<QName, ChoiceNode> mapChildElementsFromChoices(final DataNodeContainer schema, final Iterable<DataSchemaNode> childNodes) {
Map<QName, ChoiceNode> mappedChoices = Maps.newLinkedHashMap();
for (final DataSchemaNode childSchema : childNodes) {
}
private static boolean isFromAugment(final DataNodeContainer schema, final DataSchemaNode childSchema) {
- if(schema instanceof AugmentationTarget == false) {
+ if (!(schema instanceof AugmentationTarget)) {
return false;
}
for (DataSchemaNode child : ((DataNodeContainer) schema).getChildNodes()) {
// If is not augmented child, continue
- if (augments.containsKey(child.getQName()) == false) {
+ if (!(augments.containsKey(child.getQName()))) {
continue;
}
// Choice Node has to map child nodes from all its cases
if (schema instanceof ChoiceNode) {
for (ChoiceCaseNode choiceCaseNode : ((ChoiceNode) schema).getCases()) {
- if (augments.containsKey(choiceCaseNode.getQName()) == false) {
+ if (!(augments.containsKey(choiceCaseNode.getQName()))) {
continue;
}
*
*/
public static Set<DataSchemaNode> getRealSchemasForAugment(final AugmentationTarget targetSchema, final AugmentationSchema augmentSchema) {
- if(targetSchema.getAvailableAugmentations().contains(augmentSchema) == false) {
+ if (!(targetSchema.getAvailableAugmentations().contains(augmentSchema))) {
return Collections.emptySet();
}
for (ChoiceCaseNode choiceCaseNode : schema.getCases()) {
if (child instanceof AugmentationNode
&& belongsToCaseAugment(choiceCaseNode,
- (InstanceIdentifier.AugmentationIdentifier) child.getIdentifier())) {
+ (YangInstanceIdentifier.AugmentationIdentifier) child.getIdentifier())) {
return Optional.of(choiceCaseNode);
} else if (choiceCaseNode.getDataChildByName(child.getNodeType()) != null) {
return Optional.of(choiceCaseNode);
return Optional.absent();
}
- public static boolean belongsToCaseAugment(final ChoiceCaseNode caseNode, final InstanceIdentifier.AugmentationIdentifier childToProcess) {
+ public static boolean belongsToCaseAugment(final ChoiceCaseNode caseNode, final YangInstanceIdentifier.AugmentationIdentifier childToProcess) {
for (AugmentationSchema augmentationSchema : caseNode.getAvailableAugmentations()) {
Set<QName> currentAugmentChildNodes = Sets.newHashSet();
return false;
}
- public static InstanceIdentifier.AugmentationIdentifier getNodeIdentifierForAugmentation(final AugmentationSchema schema) {
- return new InstanceIdentifier.AugmentationIdentifier(getChildQNames(schema));
+ public static YangInstanceIdentifier.AugmentationIdentifier getNodeIdentifierForAugmentation(final AugmentationSchema schema) {
+ return new YangInstanceIdentifier.AugmentationIdentifier(getChildQNames(schema));
}
public static Set<QName> getChildQNames(final AugmentationSchema schema) {