X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fdom%2Fbroker%2Futil%2FYangSchemaUtils.java;h=cd1a792d677cd7e4cbaead37b652cd2e8d9a4f21;hp=a478aaac97779b0499eb684797e8cbc220d8df24;hb=cf1a8da1f3ee11170ce05611d85d15b1aceed8e8;hpb=2e29ba0089e109c71af6fae1a6811255f9845049 diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java index a478aaac97..cd1a792d67 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java @@ -7,6 +7,11 @@ */ package org.opendaylight.controller.sal.dom.broker.util; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkState; + +import com.google.common.base.Function; +import com.google.common.collect.FluentIterable; import java.util.Iterator; import java.util.List; @@ -32,17 +37,12 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.model.api.UsesNode; -import static com.google.common.base.Preconditions.*; - -import com.google.common.base.Function; -import com.google.common.collect.FluentIterable; - -public class YangSchemaUtils { +public final class YangSchemaUtils { private static final Function QNAME_FROM_PATH_ARGUMENT = new Function(){ @Override - public QName apply(PathArgument input) { + public QName apply(final PathArgument input) { if(input == null) { return null; } @@ -50,18 +50,17 @@ public class YangSchemaUtils { } }; - private YangSchemaUtils() { + private YangSchemaUtils() { throw new UnsupportedOperationException("Utility class."); } - - public static DataSchemaNode getSchemaNode(SchemaContext schema,InstanceIdentifier path) { + public static DataSchemaNode getSchemaNode(final SchemaContext schema,final InstanceIdentifier path) { checkArgument(schema != null,"YANG Schema must not be null."); checkArgument(path != null,"Path must not be null."); - return getSchemaNode(schema, FluentIterable.from(path.getPath()).transform(QNAME_FROM_PATH_ARGUMENT)); + return getSchemaNode(schema, FluentIterable.from(path.getPathArguments()).transform(QNAME_FROM_PATH_ARGUMENT)); } - public static DataSchemaNode getSchemaNode(SchemaContext schema,Iterable path) { + public static DataSchemaNode getSchemaNode(final SchemaContext schema,final Iterable path) { checkArgument(schema != null,"YANG Schema must not be null."); checkArgument(path != null,"Path must not be null."); if(!path.iterator().hasNext()){ @@ -92,9 +91,8 @@ public class YangSchemaUtils { return (DataSchemaNode) previous; } - private static DataSchemaNode searchInChoices(DataNodeContainer node, QName arg) { - Set children = node.getChildNodes(); - for (DataSchemaNode child : children) { + private static DataSchemaNode searchInChoices(final DataNodeContainer node, final QName arg) { + for (DataSchemaNode child : node.getChildNodes()) { if (child instanceof ChoiceNode) { ChoiceNode choiceNode = (ChoiceNode) child; DataSchemaNode potential = searchInCases(choiceNode, arg); @@ -106,7 +104,7 @@ public class YangSchemaUtils { return null; } - private static DataSchemaNode searchInCases(ChoiceNode choiceNode, QName arg) { + private static DataSchemaNode searchInCases(final ChoiceNode choiceNode, final QName arg) { Set cases = choiceNode.getCases(); for (ChoiceCaseNode caseNode : cases) { DataSchemaNode node = caseNode.getDataChildByName(arg); @@ -117,13 +115,13 @@ public class YangSchemaUtils { return null; } - private static ContainerSchemaNode toRootDataNode(SchemaContext schema) { + private static ContainerSchemaNode toRootDataNode(final SchemaContext schema) { return new NetconfDataRootNode(schema); } private static final class NetconfDataRootNode implements ContainerSchemaNode { - public NetconfDataRootNode(SchemaContext schema) { + public NetconfDataRootNode(final SchemaContext schema) { // TODO Auto-generated constructor stub } @@ -146,13 +144,13 @@ public class YangSchemaUtils { } @Override - public DataSchemaNode getDataChildByName(QName name) { + public DataSchemaNode getDataChildByName(final QName name) { // TODO Auto-generated method stub return null; } @Override - public DataSchemaNode getDataChildByName(String name) { + public DataSchemaNode getDataChildByName(final String name) { // TODO Auto-generated method stub return null; }