--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang</artifactId>\r
+ <version>1.0</version>\r
+ <packaging>pom</packaging>\r
+ <modules>\r
+ <module>yang-common</module>\r
+ <module>yang-data-api</module>\r
+ <module>yang-data-util</module>\r
+ <module>yang-model-api</module>\r
+ <module>yang-model-util</module>\r
+ <module>yang-binding</module>\r
+ </modules>\r
+ <dependencies>\r
+\r
+ <dependency>\r
+ <groupId>junit</groupId>\r
+ <artifactId>junit</artifactId>\r
+ <version>4.10</version>\r
+ <scope>test</scope>\r
+ <optional>true</optional>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-api</artifactId>\r
+ <version>1.7.2</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-simple</artifactId>\r
+ <version>1.7.2</version>\r
+ </dependency>\r
+ </dependencies>\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-compiler-plugin</artifactId>\r
+ <version>2.0</version>\r
+ <inherited>true</inherited>\r
+ <configuration>\r
+ <source>1.6</source>\r
+ <target>1.6</target>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-javadoc-plugin</artifactId>\r
+ <version>2.8.1</version>\r
+ <configuration>\r
+ <stylesheet>maven</stylesheet>\r
+ </configuration>\r
+ <executions>\r
+ <execution>\r
+ <goals>\r
+ <goal>aggregate</goal>\r
+ </goals>\r
+ <phase>site</phase>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+ <reporting>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.codehaus.mojo</groupId>\r
+ <artifactId>findbugs-maven-plugin</artifactId>\r
+ <version>2.4.0</version>\r
+ <configuration>\r
+ <effort>Max</effort>\r
+ <threshold>Low</threshold>\r
+ <goal>site</goal>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.codehaus.mojo</groupId>\r
+ <artifactId>jdepend-maven-plugin</artifactId>\r
+ <version>2.0-beta-2</version>\r
+ </plugin>\r
+ </plugins>\r
+ </reporting>\r
+</project>\r
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang</artifactId>\r
+ <version>1.0</version>\r
+ </parent>\r
+ <artifactId>yang-binding</artifactId>\r
+</project>
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.binding;\r
+\r
+/**\r
+ * \r
+ * \r
+ */\r
+public interface DataRoot {\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.binding;\r
+\r
+/**\r
+ * Marker interface for YANG-defined notifications\r
+ * \r
+ * \r
+ */\r
+public interface Notification {\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.binding;\r
+\r
+/**\r
+ * Marker interface for generated notification listener interfaces\r
+ * \r
+ * \r
+ * \r
+ */\r
+public interface NotificationListener {\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.binding;\r
+\r
+/**\r
+ * Marker interface for tagging generated YANG Modules\r
+ * \r
+ */\r
+public interface RpcService {\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.binding;
\ No newline at end of file
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang</artifactId>\r
+ <version>1.0</version>\r
+ </parent>\r
+ <artifactId>yang-common</artifactId>\r
+</project>
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.common;\r
+\r
+import java.net.URI;\r
+import java.net.URISyntaxException;\r
+\r
+import java.text.SimpleDateFormat;\r
+import java.util.Date;\r
+\r
+/**\r
+ * The QName from XML consists of local name of element and XML namespace, but\r
+ * for our use, we added module revision to it.\r
+ * \r
+ * In YANG context QName is full name of defined node, type, procedure or\r
+ * notification. QName consists of XML namespace, YANG model revision and local\r
+ * name of defined type. It is used to prevent name clashes between nodes with\r
+ * same local name, but from different schemas.\r
+ * \r
+ * <ul>\r
+ * <li><b>XMLNamespace</b> - the namespace assigned to the YANG module which\r
+ * defined element, type, procedure or notification.</li>\r
+ * <li><b>Revision</b> - the revision of the YANG module which describes the\r
+ * element</li>\r
+ * <li><b>LocalName</b> - the YANG schema identifier which were defined for this\r
+ * node in the YANG module</li>\r
+ * </ul>\r
+ * \r
+ * \r
+ */\r
+public class QName {\r
+\r
+ private SimpleDateFormat revisionFormat = new SimpleDateFormat("yyyy-MM-dd");\r
+\r
+ final URI namespace;\r
+ final String localName;\r
+ final String prefix;\r
+ final Date revision;\r
+\r
+ /**\r
+ * QName Constructor.\r
+ * \r
+ * @param namespace\r
+ * the namespace assigned to the YANG module\r
+ * @param revision\r
+ * the revision of the YANG module\r
+ * @param prefix\r
+ * locally defined prefix assigned to local name\r
+ * @param localName\r
+ * YANG schema identifier\r
+ */\r
+ public QName(URI namespace, Date revision, String prefix, String localName) {\r
+ this.namespace = namespace;\r
+ this.localName = localName;\r
+ this.revision = revision;\r
+ this.prefix = prefix;\r
+ }\r
+\r
+ /**\r
+ * QName Constructor.\r
+ * \r
+ * @param namespace\r
+ * the namespace assigned to the YANG module\r
+ * @param localName\r
+ * YANG schema identifier\r
+ */\r
+ public QName(URI namespace, String localName) {\r
+ this(namespace, null, "", localName);\r
+ }\r
+\r
+ /**\r
+ * QName Constructor.\r
+ * \r
+ * @param namespace\r
+ * the namespace assigned to the YANG module\r
+ * @param revision\r
+ * the revision of the YANG module\r
+ * @param localName\r
+ * YANG schema identifier\r
+ */\r
+ public QName(URI namespace, Date revision, String localName) {\r
+ this(namespace, revision, null, localName);\r
+ }\r
+\r
+ public QName(QName base, String localName) {\r
+ this(base.getNamespace(), base.getRevision(), base.getPrefix(),\r
+ localName);\r
+ }\r
+\r
+ /**\r
+ * Returns XMLNamespace assigned to the YANG module.\r
+ * \r
+ * @return XMLNamespace assigned to the YANG module.\r
+ */\r
+ public URI getNamespace() {\r
+ return namespace;\r
+ }\r
+\r
+ /**\r
+ * Returns YANG schema identifier which were defined for this node in the\r
+ * YANG module\r
+ * \r
+ * @return YANG schema identifier which were defined for this node in the\r
+ * YANG module\r
+ */\r
+ public String getLocalName() {\r
+ return localName;\r
+ }\r
+\r
+ /**\r
+ * Returns revision of the YANG module if the module has defined revision,\r
+ * otherwise returns <code>null</code>\r
+ * \r
+ * @return revision of the YANG module if the module has defined revision,\r
+ * otherwise returns <code>null</code>\r
+ */\r
+ public Date getRevision() {\r
+ return revision;\r
+ }\r
+\r
+ /**\r
+ * Returns locally defined prefix assigned to local name\r
+ * \r
+ * @return locally defined prefix assigned to local name\r
+ */\r
+ public String getPrefix() {\r
+ return prefix;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((localName == null) ? 0 : localName.hashCode());\r
+ result = prime * result\r
+ + ((namespace == null) ? 0 : namespace.hashCode());\r
+ result = prime * result\r
+ + ((revision == null) ? 0 : revision.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (obj == null)\r
+ return false;\r
+ if (getClass() != obj.getClass())\r
+ return false;\r
+ QName other = (QName) obj;\r
+ if (localName == null) {\r
+ if (other.localName != null)\r
+ return false;\r
+ } else if (!localName.equals(other.localName))\r
+ return false;\r
+ if (namespace == null) {\r
+ if (other.namespace != null)\r
+ return false;\r
+ } else if (!namespace.equals(other.namespace))\r
+ return false;\r
+ if (revision == null) {\r
+ if (other.revision != null)\r
+ return false;\r
+ } else if (!revision.equals(other.revision))\r
+ return false;\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder sb = new StringBuilder();\r
+ if (namespace != null) {\r
+ sb.append("(" + namespace);\r
+\r
+ if (revision != null) {\r
+ sb.append("?revision=" + revisionFormat.format(revision));\r
+ }\r
+ sb.append(")");\r
+ }\r
+ sb.append(localName);\r
+ return sb.toString();\r
+ }\r
+\r
+ /**\r
+ * Returns a namespace in form defined by section 5.6.4. of {@link https\r
+ * ://tools.ietf.org/html/rfc6020}, if namespace is not correctly defined,\r
+ * the method will return <code>null</code> <br>\r
+ * example "http://example.acme.com/system?revision=2008-04-01"\r
+ * \r
+ * @return namespace in form defined by section 5.6.4. of {@link https\r
+ * ://tools.ietf.org/html/rfc6020}, if namespace is not correctly\r
+ * defined, the method will return <code>null</code>\r
+ * \r
+ */\r
+ URI getRevisionNamespace() {\r
+\r
+ if (namespace == null)\r
+ return null;\r
+\r
+ String query = "";\r
+ if (revision != null) {\r
+ query = "revision=" + revisionFormat.format(revision);\r
+ }\r
+\r
+ URI compositeURI = null;\r
+ try {\r
+ compositeURI = new URI(namespace.getScheme(),\r
+ namespace.getUserInfo(), namespace.getHost(),\r
+ namespace.getPort(), namespace.getPath(), query,\r
+ namespace.getFragment());\r
+ } catch (URISyntaxException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return compositeURI;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.common;\r
+\r
+//import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
+\r
+public interface RpcError {\r
+ ErrorSeverity getSeverity();\r
+\r
+ String getTag();\r
+\r
+ String getApplicationTag();\r
+\r
+ String getMessage();\r
+\r
+ String getInfo();\r
+\r
+ // RevisionAwareXPath getPath();\r
+\r
+ public enum ErrorSeverity {\r
+ ERROR, WARNING,\r
+ }\r
+\r
+ public enum ErrorType {\r
+ TRANSPORT, RPC, PROTOCOL, APPLICATION\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.common;\r
+\r
+import java.util.Collection;\r
+\r
+public interface RpcResult<T> {\r
+ boolean isSuccessful();\r
+\r
+ T getResult();\r
+\r
+ Collection<RpcError> getErrors();\r
+}\r
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang</artifactId>\r
+ <version>1.0</version>\r
+ </parent>\r
+ <artifactId>yang-data-api</artifactId>\r
+ \r
+ \r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang-common</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ </dependencies>\r
+</project>
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.data.api;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+/**\r
+ * Composite node represents a branch in the data tree, which could contain\r
+ * nested composite nodes or leaf nodes. In the terms of the XML the simple node\r
+ * is element which does not text data directly (CDATA or PCDATA), only other\r
+ * nodes. The composite node is the manifestation of the following data schema\r
+ * constructs in the YANG:\r
+ * \r
+ * <ul>\r
+ * <li><b>container</b> - the composite node represents the YANG container and\r
+ * could contain all children schema nodes of that container</li>\r
+ * <li><b>item</b> in the <b>list</b> - the composite node represents one item\r
+ * in the YANG list and could contain all children schema nodes of that list\r
+ * item.</li>\r
+ * <li><b>anyxml</b></li>\r
+ * </ul>\r
+ * \r
+ * \r
+ */\r
+public interface CompositeNode extends Node<List<Node<?>>> {\r
+\r
+ List<Node<?>> getChildren();\r
+\r
+ List<CompositeNode> getCompositesByName(QName children);\r
+\r
+ List<CompositeNode> getCompositesByName(String children);\r
+\r
+ List<SimpleNode<?>> getSimpleNodesByName(QName children);\r
+\r
+ List<SimpleNode<?>> getSimpleNodesByName(String children);\r
+\r
+ CompositeNode getFirstCompositeByName(QName container);\r
+\r
+ SimpleNode<?> getFirstSimpleByName(QName leaf);\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.data.api;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+/**\r
+ * For the use cases of changing the state data, the node modifications are\r
+ * modeled as part of additional metadata in data tree. The modification types\r
+ * are based on Netconf edit-config RPCs. In order to modify the configuration\r
+ * or state data tree the user must create a tree representing the modification\r
+ * of the data and apply that modification to the target tree.\r
+ * \r
+ * \r
+ * @see <a href="http://tools.ietf.org/html/rfc6241">Network Configuration\r
+ * Protocol (NETCONF)</a>\r
+ * \r
+ */\r
+public interface CompositeNodeModification extends CompositeNode {\r
+\r
+ ModifyAction getModificationAction();\r
+\r
+ // Container Modification\r
+\r
+ /**\r
+ * The data identified by the node containing this modification is merged\r
+ * with the data at the corresponding level in the data tree\r
+ * \r
+ * @param node\r
+ * in data tree\r
+ */\r
+ void mergeChild(CompositeNode node);\r
+\r
+ /**\r
+ * The data identified by the node containing this modification replaces any\r
+ * related data in the target data tree If no such data exists in the target\r
+ * data tree, the child node is created.\r
+ * \r
+ * @param node\r
+ * composite node\r
+ */\r
+ void replaceChild(CompositeNode node);\r
+\r
+ /**\r
+ * Adds new composite node into data tree\r
+ * \r
+ * @param node\r
+ * composite node\r
+ */\r
+ void addChild(CompositeNode node);\r
+\r
+ /**\r
+ * The data identified by the node containing this modification is deleted\r
+ * from the target data tree if and only if the data currently exists in the\r
+ * target data tree. If the data does not exist, an error is returned with\r
+ * an error value of "data-missing".\r
+ * \r
+ * @param node\r
+ */\r
+ void deleteChild(CompositeNode node);\r
+\r
+ /**\r
+ * The data identified by the node containing this attribute is deleted from\r
+ * the target data tree if the data currently exists in the target data\r
+ * tree. If the data does not exist, the modification is silently ignored.\r
+ * \r
+ * @param node\r
+ * composite node\r
+ */\r
+ void removeChild(CompositeNode node);\r
+\r
+ // Leaf Modifications\r
+\r
+ /**\r
+ * The data identified by the node containing this modification replaces any\r
+ * related data in the target data tree If no such data exists in the target\r
+ * data tree, it is created.\r
+ * \r
+ * @param leaf\r
+ */\r
+ void replaceSimpleNode(SimpleNode<?> leaf);\r
+\r
+ /**\r
+ * The data identified by the node containing this modification is deleted\r
+ * from the target data tree if and only if the data currently exists in the\r
+ * target data tree. If the data does not exist, an error is returned with\r
+ * an error value of "data-missing".\r
+ * \r
+ * @param leaf\r
+ */\r
+ void deleteSimpleNode(SimpleNode<?> leaf);\r
+\r
+ /**\r
+ * The data identified by the node containing this attribute is deleted from\r
+ * the target data tree if the data currently exists in the target data\r
+ * tree. If the data does not exist, the modification is silently ignored.\r
+ * \r
+ * @param leaf\r
+ */\r
+ void removeSimpleNode(SimpleNode<?> leaf);\r
+\r
+ void removeLeaf(SimpleNode<?> leaf);\r
+\r
+ void removeLeaf(QName leaf);\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.data.api;\r
+\r
+public enum ModifyAction {\r
+ MERGE, REPLACE, CREATE, DELETE, REMOVE\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.data.api;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+/**\r
+ * Base representation of node in the data tree, defines basic parameters of\r
+ * node such as a QName.\r
+ * \r
+ * \r
+ * @param <T>\r
+ */\r
+public interface Node<T> {\r
+\r
+ /**\r
+ * Returns the name of the Node\r
+ * \r
+ * @return\r
+ */\r
+ QName getNodeType();\r
+\r
+ /**\r
+ * Returns parent node\r
+ * \r
+ * @return parent node\r
+ */\r
+ CompositeNode getParent();\r
+\r
+ /**\r
+ * Returns the value that holds current node, if no value is defined method\r
+ * can return <code>null</code>\r
+ * \r
+ * @return Returns the value that holds current node.\r
+ */\r
+ T getValue();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.data.api;\r
+\r
+/**\r
+ * Simple node represents a leaf in the data tree, which does not contain any\r
+ * nested nodes, but the value of node. In the terms of the XML the simple node\r
+ * is element which contains only text data (CDATA or PCDATA). The simple node\r
+ * is the manifestation of the following data schema constructs in YANG:\r
+ * <ul>\r
+ * <li><b>leaf</b> - simple node could represent YANG leafs of all types except\r
+ * the empty type, which in XML form is similar to the empty container.</li>\r
+ * <li><b>item</b> in <b>leaf-list</b></li>\r
+ * </ul>\r
+ * \r
+ * \r
+ * @param <T>\r
+ */\r
+public interface SimpleNode<T> extends Node<T> {\r
+\r
+}\r
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang</artifactId>\r
+ <version>1.0</version>\r
+ </parent>\r
+ <artifactId>yang-data-util</artifactId>\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang-data-api</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ </dependencies>\r
+</project>
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.data.util;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.data.api.CompositeNode;\r
+import org.opendaylight.controller.yang.data.api.Node;\r
+import org.opendaylight.controller.yang.data.api.SimpleNode;\r
+\r
+public abstract class AbstractContainerNode extends AbstractNode<List<Node<?>>>\r
+ implements CompositeNode {\r
+\r
+ public SimpleNode<?> getFirstSimpleByName(QName leaf) {\r
+ List<SimpleNode<?>> list = getSimpleNodesByName(leaf);\r
+ if (list.size() == 0)\r
+ return null;\r
+ return list.get(0);\r
+ }\r
+\r
+ protected AbstractContainerNode(QName name, CompositeNode parent) {\r
+ super(name, parent);\r
+ }\r
+\r
+ public AbstractContainerNode(QName name) {\r
+ super(name, null);\r
+ }\r
+\r
+ public List<Node<?>> getChildren() {\r
+ return getValue();\r
+ }\r
+\r
+ public List<Node<?>> getValue() {\r
+ Map<QName, List<Node<?>>> map = getNodeMap();\r
+ if (map == null)\r
+ throw new IllegalStateException("nodeMap should not be null");\r
+ List<Node<?>> ret = new ArrayList<Node<?>>();\r
+ Collection<List<Node<?>>> values = map.values();\r
+ for (List<Node<?>> list : values) {\r
+ ret.addAll(list);\r
+ }\r
+ return ret;\r
+ }\r
+\r
+ protected abstract Map<QName, List<Node<?>>> getNodeMap();\r
+\r
+ public List<CompositeNode> getCompositesByName(QName children) {\r
+ Map<QName, List<Node<?>>> map = getNodeMap();\r
+ if (map == null)\r
+ throw new IllegalStateException("nodeMap should not be null");\r
+ List<Node<?>> toFilter = map.get(children);\r
+ List<CompositeNode> list = new ArrayList<CompositeNode>();\r
+ for (Node<?> node : toFilter) {\r
+ if (node instanceof CompositeNode)\r
+ list.add((CompositeNode) node);\r
+ }\r
+ return list;\r
+ }\r
+\r
+ public List<SimpleNode<?>> getSimpleNodesByName(QName children) {\r
+ Map<QName, List<Node<?>>> map = getNodeMap();\r
+ if (map == null)\r
+ throw new IllegalStateException("nodeMap should not be null");\r
+ List<Node<?>> toFilter = map.get(children);\r
+ List<SimpleNode<?>> list = new ArrayList<SimpleNode<?>>();\r
+\r
+ for (Node<?> node : toFilter) {\r
+ if (node instanceof SimpleNode<?>)\r
+ list.add((SimpleNode<?>) node);\r
+ }\r
+ return list;\r
+ }\r
+\r
+ public CompositeNode getFirstCompositeByName(QName container) {\r
+ List<CompositeNode> list = getCompositesByName(container);\r
+ if (list.size() == 0)\r
+ return null;\r
+ return list.get(0);\r
+ }\r
+\r
+ public SimpleNode<?> getFirstLeafByName(QName leaf) {\r
+ List<SimpleNode<?>> list = getSimpleNodesByName(leaf);\r
+ if (list.size() == 0)\r
+ return null;\r
+ return list.get(0);\r
+ }\r
+\r
+ public List<CompositeNode> getCompositesByName(String children) {\r
+ return getCompositesByName(localQName(children));\r
+ }\r
+\r
+ public List<SimpleNode<?>> getSimpleNodesByName(String children) {\r
+ return getSimpleNodesByName(localQName(children));\r
+ }\r
+\r
+ private QName localQName(String str) {\r
+ return new QName(getNodeType(), str);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.data.util;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.data.api.CompositeNode;\r
+import org.opendaylight.controller.yang.data.api.Node;\r
+\r
+public abstract class AbstractNode<T> implements Node<T> {\r
+\r
+ private final QName nodeName;\r
+ private final CompositeNode parent;\r
+\r
+ protected AbstractNode(QName name, CompositeNode parent) {\r
+ nodeName = name;\r
+ this.parent = parent;\r
+ }\r
+\r
+ public QName getNodeType() {\r
+ return this.nodeName;\r
+ }\r
+\r
+ public CompositeNode getParent() {\r
+ return parent;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.data.util;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.data.api.CompositeNode;\r
+import org.opendaylight.controller.yang.data.api.Node;\r
+import org.opendaylight.controller.yang.data.api.SimpleNode;\r
+\r
+public class Nodes {\r
+\r
+ private Nodes() {\r
+ }\r
+\r
+ public static <T> SimpleNode<T> leafNode(QName name, T value) {\r
+ return new SimpleNodeTO<T>(name, value, null);\r
+ }\r
+\r
+ public static CompositeNode containerNode(QName name, List<Node<?>> children) {\r
+ return containerNode(name, children, null);\r
+ }\r
+\r
+ public static CompositeNode containerNode(QName name,\r
+ List<Node<?>> children, CompositeNode parent) {\r
+ return new ContainerNodeTO(name, parent, nodeMapFromList(children));\r
+ }\r
+\r
+ public static Map<QName, List<Node<?>>> nodeMapFromList(\r
+ List<Node<?>> children) {\r
+ Map<QName, List<Node<?>>> map = new HashMap<QName, List<Node<?>>>();\r
+ for (Node<?> node : children) {\r
+\r
+ QName name = node.getNodeType();\r
+ List<Node<?>> targetList = map.get(name);\r
+ if (targetList == null) {\r
+ targetList = new ArrayList<Node<?>>();\r
+ map.put(name, targetList);\r
+ }\r
+ targetList.add(node);\r
+ }\r
+ return map;\r
+ }\r
+\r
+ private static class ContainerNodeTO extends AbstractContainerNode {\r
+\r
+ private final Map<QName, List<Node<?>>> nodeMap;\r
+\r
+ public ContainerNodeTO(QName name, Map<QName, List<Node<?>>> nodeMap) {\r
+ super(name);\r
+ this.nodeMap = nodeMap;\r
+ }\r
+\r
+ public ContainerNodeTO(QName name, CompositeNode parent,\r
+ Map<QName, List<Node<?>>> nodeMap) {\r
+ super(name, parent);\r
+ this.nodeMap = nodeMap;\r
+ }\r
+\r
+ @Override\r
+ protected Map<QName, List<Node<?>>> getNodeMap() {\r
+\r
+ return nodeMap;\r
+ }\r
+ }\r
+\r
+ private static class SimpleNodeTO<T> extends AbstractNode<T> implements\r
+ SimpleNode<T> {\r
+\r
+ private final T value;\r
+\r
+ protected SimpleNodeTO(QName name, T val, CompositeNode parent) {\r
+ super(name, parent);\r
+ value = val;\r
+\r
+ }\r
+\r
+ @Override\r
+ public T getValue() {\r
+ return value;\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang</artifactId>\r
+ <version>1.0</version>\r
+ </parent>\r
+ <artifactId>yang-model-api</artifactId>\r
+ \r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang-common</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ </dependencies>\r
+</project>
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+/**\r
+ * The binary built-in type represents any binary data, i.e., a sequence of\r
+ * octets. <br>\r
+ * <br>\r
+ * Binary values are encoded with the base64 encoding scheme (see <a\r
+ * href="https://tools.ietf.org/html/rfc4648#section-4">[RFC4648], Section\r
+ * 4</a>). <br>\r
+ * The canonical form of a binary value follows the rules in <a\r
+ * href="https://tools.ietf.org/html/rfc4648">[RFC4648]</a>.\r
+ * \r
+ * \r
+ */\r
+public interface BinaryTypeDefinition extends\r
+ TypeDefinition<BinaryTypeDefinition> {\r
+\r
+ /**\r
+ * Returns the number of octets it that binary value contains.\r
+ * \r
+ * @return the number of octets it that binary value contains.\r
+ */\r
+ public LengthConstraint getLengthConstraint();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.model.api.SchemaNode;\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface BitsTypeDefinition extends TypeDefinition<BitsTypeDefinition> {\r
+\r
+ public List<Bit> getBits();\r
+\r
+ interface Bit extends SchemaNode {\r
+ /**\r
+ * The position value MUST be in the range 0 to 4294967295, and it MUST\r
+ * be unique within the bits type.\r
+ * \r
+ * @return The position value of bit in range from 0 to 4294967295.\r
+ */\r
+ public Long getPosition();\r
+\r
+ public String getName();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface BooleanTypeDefinition extends\r
+ TypeDefinition<BooleanTypeDefinition> {\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface DecimalTypeDefinition extends\r
+ TypeDefinition<DecimalTypeDefinition> {\r
+\r
+ List<RangeConstraint> getRangeStatements();\r
+\r
+ /**\r
+ * Returns integer between 1 and 18 inclusively. <br>\r
+ * <br>\r
+ * \r
+ * The "fraction-digits" statement controls the size of the minimum\r
+ * difference between values of a decimal64 type, by restricting the value\r
+ * space to numbers that are expressible as "i x 10^-n" where n is the\r
+ * fraction-digits argument.\r
+ * \r
+ * @return\r
+ */\r
+ Integer getFractionDigits();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface EmptyTypeDefinition extends\r
+ TypeDefinition<EmptyTypeDefinition> {\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.model.api.SchemaNode;\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface EnumTypeDefinition extends TypeDefinition<EnumTypeDefinition> {\r
+\r
+ List<EnumPair> getValues();\r
+\r
+ interface EnumPair extends SchemaNode {\r
+\r
+ /**\r
+ * The name to specify each assigned name of an enumeration type.\r
+ * \r
+ * @return name of each assigned name of an enumeration type.\r
+ */\r
+ public String getName();\r
+\r
+ /**\r
+ * The "value" statement, which is optional, is used to associate an\r
+ * integer value with the assigned name for the enum. This integer value\r
+ * MUST be in the range -2147483648 to 2147483647, and it MUST be unique\r
+ * within the enumeration type.\r
+ * \r
+ * @return integer value assigned to enumeration\r
+ */\r
+ public Integer getValue();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface IdentityTypeDefinition extends\r
+ TypeDefinition<IdentityTypeDefinition> {\r
+\r
+ public QName getIdentityName();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface IdentityrefTypeDefinition extends\r
+ TypeDefinition<IdentityTypeDefinition> {\r
+\r
+ public IdentityTypeDefinition getIdentity();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface InstanceIdentifierTypeDefinition extends\r
+ TypeDefinition<InstanceIdentifierTypeDefinition> {\r
+\r
+ public RevisionAwareXPath getPathStatement();\r
+\r
+ public boolean requireInstance();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface IntegerTypeDefinition extends\r
+ TypeDefinition<IntegerTypeDefinition> {\r
+\r
+ List<RangeConstraint> getRangeStatements();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface LeafrefTypeDefinition extends\r
+ TypeDefinition<LeafrefTypeDefinition> {\r
+\r
+ public RevisionAwareXPath getPathStatement();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import org.opendaylight.controller.yang.model.api.ConstraintMetaDefinition;\r
+\r
+public interface LengthConstraint extends ConstraintMetaDefinition {\r
+\r
+ Long getMin();\r
+\r
+ Long getMax();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import org.opendaylight.controller.yang.model.api.ConstraintMetaDefinition;\r
+\r
+public interface PatternConstraint extends ConstraintMetaDefinition {\r
+\r
+ public String getRegularExpression();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import org.opendaylight.controller.yang.model.api.ConstraintMetaDefinition;\r
+\r
+public interface RangeConstraint extends ConstraintMetaDefinition {\r
+\r
+ Long getMin();\r
+\r
+ Long getMax();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface StringTypeDefinition extends\r
+ TypeDefinition<StringTypeDefinition> {\r
+\r
+ List<LengthConstraint> getLengthStatements();\r
+\r
+ List<PatternConstraint> getPatterns();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface UnionTypeDefinition extends\r
+ TypeDefinition<UnionTypeDefinition> {\r
+\r
+ public List<TypeDefinition<?>> getTypes();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface UnknownTypeDefinition extends\r
+ TypeDefinition<UnknownTypeDefinition> {\r
+\r
+ public List<RangeConstraint> getRangeStatements();\r
+\r
+ public List<LengthConstraint> getLengthStatements();\r
+\r
+ public List<PatternConstraint> getPatterns();\r
+\r
+ public LengthConstraint getLengthConstraint();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.api.type;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public interface UnsignedIntegerTypeDefinition extends\r
+ TypeDefinition<UnsignedIntegerTypeDefinition> {\r
+\r
+ List<RangeConstraint> getRangeStatements();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+/**\r
+ * The "anyxml" interface defines an interior node in the schema tree. It takes\r
+ * one argument, which is an identifier represented by QName inherited from\r
+ * {@link SchemaNode}, followed by a block of substatements that holds detailed\r
+ * anyxml information. The substatements are defined in {@link DataSchemaNode} <br>\r
+ * <br>\r
+ * This interface was modeled according to definition in <a\r
+ * href="https://tools.ietf.org/html/rfc6020#section-7.10">[RFC-6020] The anyxml\r
+ * Statement</a>\r
+ * \r
+ * \r
+ */\r
+public interface AnyXmlSchemaNode extends DataSchemaNode {\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.Set;\r
+\r
+public interface AugmentationSchema extends DataNodeContainer {\r
+\r
+ String getDescription();\r
+\r
+ String getReference();\r
+\r
+ Status getStatus();\r
+\r
+ SchemaPath getTargetPath();\r
+\r
+ Set<UsesNode> getUses();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.Set;\r
+\r
+public interface AugmentationTarget {\r
+ /**\r
+ * Returns a set of augmentations targeting this element.\r
+ * \r
+ * @return\r
+ */\r
+ Set<AugmentationSchema> getAvailableAugmentations();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface ChoiceCaseNode extends DataSchemaNode, DataNodeContainer,\r
+ AugmentationTarget {\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.Set;\r
+\r
+public interface ChoiceNode extends DataSchemaNode {\r
+\r
+ Set<ChoiceCaseNode> getCases();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.Set;\r
+\r
+public interface ConstraintDefinition {\r
+ DataSchemaNode getParent();\r
+\r
+ RevisionAwareXPath getWhenCondition();\r
+\r
+ Set<MustDefinition> getMustConstraints();\r
+\r
+ boolean isMandatory();\r
+\r
+ Integer getMinElements();\r
+\r
+ Integer getMaxElements();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface ConstraintMetaDefinition {\r
+\r
+ String getDescription();\r
+\r
+ String getErrorAppTag();\r
+\r
+ String getErrorMessage();\r
+\r
+ String getReference();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.Set;\r
+\r
+public interface ContainerSchemaNode extends DataNodeContainer,\r
+ AugmentationTarget, DataSchemaNode {\r
+\r
+ Set<UsesNode> getUses();\r
+\r
+ boolean isPresenceContainer();\r
+\r
+ MustDefinition getMustDefinition();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.Set;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public interface DataNodeContainer {\r
+\r
+ Set<TypeDefinition<?>> getTypeDefinitions();\r
+\r
+ Set<DataSchemaNode> getChildNodes();\r
+\r
+ Set<GroupingDefinition> getGroupings();\r
+\r
+ DataSchemaNode getDataChildByName(QName name);\r
+\r
+ DataSchemaNode getDataChildByName(String name);\r
+\r
+ Set<UsesNode> getUses();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface DataSchemaNode extends SchemaNode {\r
+\r
+ /**\r
+ * Returns <code>true</code> if the data node was added by augmentation,\r
+ * otherwise returns <code>false</code>\r
+ * \r
+ * @return <code>true</code> if the data node was added by augmentation,\r
+ * otherwise returns <code>false</code>\r
+ */\r
+ boolean isAugmenting();\r
+\r
+ /**\r
+ * Returns <code>true</code> if the data represents configuration data,\r
+ * otherwise returns <code>false</code>\r
+ * \r
+ * @return <code>true</code> if the data represents configuration data,\r
+ * otherwise returns <code>false</code>\r
+ */\r
+ boolean isConfiguration();\r
+\r
+ /**\r
+ * Returns the constraints associated with Data Schema Node\r
+ * \r
+ * @return the constraints associated with Data Schema Node\r
+ */\r
+ ConstraintDefinition getConstraints();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface Deviation {\r
+\r
+ MustDefinition getMustDefinition();\r
+\r
+ enum Deviate {\r
+ NOT_SUPPORTED, ADD, REPLACE, DELETE\r
+ }\r
+\r
+ SchemaPath getTargetPath();\r
+\r
+ Deviate getDeviate();\r
+\r
+ String getReference();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface ExtensionDefinition extends SchemaNode {\r
+\r
+ /**\r
+ * Returns the <code>String</code> that is the name of argument to the\r
+ * Keyword. If no argument statement is present the method will return\r
+ * <code>null</code> <br>\r
+ * The argument statement is defined in <a\r
+ * href="https://tools.ietf.org/html/rfc6020#section-7.17.2">[RFC-6020] The\r
+ * argument Statement</a>\r
+ * \r
+ * @return the <code>String</code> that is the name of argument to the\r
+ * Keyword. If no argument statement is present the method will\r
+ * return <code>null</code>\r
+ */\r
+ public String getArgument();\r
+\r
+ /**\r
+ * This statement indicates if the argument is mapped to an XML element in\r
+ * YIN or to an XML attribute.<br>\r
+ * By contract if implementation of ExtensionDefinition does not specify the\r
+ * yin-element statement the return value is by default set to\r
+ * <code>false</code>\r
+ * \r
+ * <br>\r
+ * <br>\r
+ * For more specific definition please look into <a\r
+ * href="https://tools.ietf.org/html/rfc6020#section-7.17.2.2">[RFC-6020]\r
+ * The yin-element Statement</a>\r
+ * \r
+ * @return <code>true</code> if the argument is mapped to an XML element in\r
+ * YIN or returns <code>false</code> if the argument is mapped to an\r
+ * XML attribute.\r
+ */\r
+ public boolean isYinElement();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface FeatureDefinition extends SchemaNode {\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.Set;\r
+\r
+public interface GroupingDefinition extends DataNodeContainer, SchemaNode {\r
+\r
+ Set<UsesNode> getUses();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface KeyDefinition extends SchemaNode {\r
+\r
+ TypeDefinition<? extends TypeDefinition<?>> getType();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface LeafListSchemaNode extends DataSchemaNode {\r
+\r
+ TypeDefinition<? extends TypeDefinition<?>> getType();\r
+\r
+ boolean isUserOrdered();\r
+\r
+ MustDefinition getMustDefinition();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface LeafSchemaNode extends DataSchemaNode {\r
+ TypeDefinition getType();\r
+\r
+ MustDefinition getMustDefinition();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public interface ListSchemaNode extends DataNodeContainer, AugmentationTarget,\r
+ DataSchemaNode {\r
+\r
+ public List<QName> getKeyDefinition();\r
+\r
+ boolean isUserOrdered();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.net.URI;\r
+import java.util.Date;\r
+import java.util.Set;\r
+\r
+public interface Module extends DataNodeContainer {\r
+\r
+ URI getNamespace();\r
+\r
+ String getName();\r
+\r
+ Date getRevision();\r
+\r
+ String getPrefix();\r
+\r
+ String getYangVersion();\r
+\r
+ String getDescription();\r
+\r
+ String getReference();\r
+\r
+ String getOrganization();\r
+\r
+ String getContact();\r
+\r
+ Set<ModuleImport> getImports();\r
+\r
+ Set<FeatureDefinition> getFeatures();\r
+\r
+ Set<NotificationDefinition> getNotifications();\r
+\r
+ Set<AugmentationSchema> getAugmentations();\r
+\r
+ Set<RpcDefinition> getRpcs();\r
+\r
+ Set<Deviation> getDeviations();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.Date;\r
+\r
+public interface ModuleImport {\r
+\r
+ String getModuleName();\r
+\r
+ Date getRevision();\r
+\r
+ String getPrefix();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface MustDefinition extends ConstraintMetaDefinition {\r
+\r
+ RevisionAwareXPath getXpath();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.Set;\r
+\r
+public interface NotificationDefinition extends SchemaNode, DataNodeContainer {\r
+ Set<UsesNode> getUses();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface RevisionAwareXPath {\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.Set;\r
+\r
+public interface RpcDefinition extends SchemaNode {\r
+\r
+ Set<TypeDefinition<?>> getTypeDefinitions();\r
+\r
+ Set<GroupingDefinition> getGroupings();\r
+\r
+ ContainerSchemaNode getInput();\r
+\r
+ ContainerSchemaNode getOutput();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public interface SchemaNode {\r
+\r
+ public QName getQName();\r
+\r
+ public SchemaPath getPath();\r
+\r
+ public String getDescription();\r
+\r
+ public String getReference();\r
+\r
+ public Status getStatus();\r
+\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public class SchemaPath {\r
+\r
+ final List<QName> path;\r
+ final boolean absolute;\r
+\r
+ public SchemaPath(final List<QName> path, boolean absolute) {\r
+ this.path = Collections.unmodifiableList(new ArrayList<QName>(path));\r
+ this.absolute = absolute;\r
+ }\r
+\r
+ public List<QName> getPath() {\r
+ return path;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + (absolute ? 1231 : 1237);\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ SchemaPath other = (SchemaPath) obj;\r
+ if (absolute != other.absolute) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("SchemaPath [path=");\r
+ builder.append(path);\r
+ builder.append(", absolute=");\r
+ builder.append(absolute);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public enum Status {\r
+ CURRENT, DEPRECATED, OBSOLOTE\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface TypeDefinition<T extends TypeDefinition<T>> extends SchemaNode {\r
+\r
+ T getBaseType();\r
+\r
+ String getUnits();\r
+\r
+ Object getDefaultValue();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
+public interface UsesNode {\r
+ SchemaPath getGroupingPath();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+/**\r
+ * Definition of structures and DOM Like API of processed YANG schema\r
+ * \r
+ * <h3>YANG Statement mapping</h3>\r
+ * \r
+ * <dl>\r
+ * <dt>anyxml\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.AnyXmlSchemaNode}\r
+ * \r
+ * <dt>argument\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ExtensionDefinition#getArgumentName()}\r
+ * \r
+ * \r
+ * <dt>augment\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.AugmentationSchema}\r
+ * \r
+ * <dt>base\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.IdentityrefTypeDefinition#getIdentity()}\r
+ * \r
+ * <dt>belongs-to\r
+ * <dd>\r
+ * \r
+ * <dt>bit\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.BitsTypeDefinition.Bit}\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.BitsTypeDefinition#getBits()}\r
+ * \r
+ * <dt>case\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ChoiceCaseNode}\r
+ * \r
+ * <dt>choice\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ChoiceNode}\r
+ * \r
+ * <dt>config\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.DataSchemaNode#isConfiguration()}\r
+ * \r
+ * <dt>contact\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.Module#getContact()}\r
+ * \r
+ * <dt>container\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ContainerSchemaNode}\r
+ * \r
+ * <dt>default\r
+ * <dd>\r
+ * \r
+ * <dt>description\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()}\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ConstraintMetaDefinition#getDescription()}\r
+ * \r
+ * <dt>enum\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.EnumTypeDefinition.EnumPair}\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.EnumTypeDefinition#getValues()}\r
+ * \r
+ * <dt>error-app-tag\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ConstraintMetaDefinition#getErrorAppTag()}\r
+ * \r
+ * <dt>error-message\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ConstraintMetaDefinition#getErrorMessage()}\r
+ * \r
+ * <dt>extension\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ExtensionDefinition}\r
+ * \r
+ * <dt>deviation\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.Deviation}\r
+ * \r
+ * <dt>deviate\r
+ * <dd>\r
+ * \r
+ * <dt>feature\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.FeatureDefinition}\r
+ * \r
+ * <dt>fraction-digits\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.DecimalTypeDefinition#getFractionDigits()}\r
+ * \r
+ * <dt>grouping\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.GroupingDefinition}\r
+ * \r
+ * <dt>identity\r
+ * <dd>\r
+ * \r
+ * <dt>if-feature\r
+ * <dd>\r
+ * \r
+ * <dt>import\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ModuleImport}\r
+ * \r
+ * <dt>include\r
+ * <dd>\r
+ * \r
+ * <dt>input\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.RpcDefinition#getInput()}\r
+ * \r
+ * <dt>key\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ListSchemaNode#getKeyDefinition()}\r
+ * \r
+ * <dt>leaf\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.LeafSchemaNode}\r
+ * \r
+ * <dt>leaf-list\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.LeafListSchemaNode}\r
+ * \r
+ * <dt>length\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.LengthConstraint}\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.StringTypeDefinition#getLengthStatements()}\r
+ * \r
+ * <dt>list\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ListSchemaNode}\r
+ * \r
+ * <dt>mandatory\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ConstraintDefinition#isMandatory()}\r
+ * \r
+ * <dt>max-elements\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ConstraintDefinition#getMinElements()}\r
+ * \r
+ * <dt>min-elements\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ConstraintDefinition#getMaxElements()}\r
+ * \r
+ * <dt>module\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.Module}\r
+ * \r
+ * <dt>must\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ConstraintDefinition#getMustConstraints()}\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.MustDefinition}\r
+ * \r
+ * <dt>namespace\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.Module#getNamespace()}\r
+ * \r
+ * <dt>notification\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.NotificationDefinition}\r
+ * \r
+ * <dt>ordered-by\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ListSchemaNode#isUserOrdered()}\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.LeafListSchemaNode#isUserOrdered()}\r
+ * \r
+ * <dt>organization\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.Module#getOrganization()}\r
+ * \r
+ * <dt>output\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.RpcDefinition#getOutput()}\r
+ * \r
+ * <dt>path\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.LeafrefTypeDefinition#getPathStatement()}\r
+ * \r
+ * <dt>pattern\r
+ * <dd>{@link org.opendaylight.controller.yang.model.base.type.api.PatternConstraint}\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.StringTypeDefinition}\r
+ * \r
+ * <dt>position\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.BitsTypeDefinition.Bit#getPosition()}\r
+ * \r
+ * <dt>prefix\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.Module#getPrefix()}\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ModuleImport#getPrefix()}\r
+ * \r
+ * <dt>presence\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ContainerSchemaNode#isPresenceContainer()}\r
+ * \r
+ * <dt>range\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.RangeConstraint}\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.IntegerTypeDefinition#getRangeStatements()}\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition#getRangeStatements()}\r
+ * \r
+ * <dt>reference\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.SchemaNode#getReference()}\r
+ * \r
+ * <dt>refine\r
+ * <dd>\r
+ * \r
+ * <dt>require-instance\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.InstanceIdentifierTypeDefinition#requireInstance()}\r
+ * \r
+ * <dt>revision\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.Module#getRevision()}\r
+ * \r
+ * <dt>revision-date\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ModuleImport#getRevision()}\r
+ * \r
+ * <dt>rpc\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.RpcDefinition}\r
+ * \r
+ * <dt>status\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()}\r
+ * \r
+ * <dt>submodule\r
+ * <dd>\r
+ * \r
+ * <dt>type\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.TypeDefinition}\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.LeafSchemaNode#getType()}\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.LeafListSchemaNode#getType()}\r
+ * \r
+ * <dt>typedef\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.TypeDefinition}\r
+ * \r
+ * <dt>unique\r
+ * <dd>\r
+ * \r
+ * <dt>units\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()}\r
+ * \r
+ * <dt>uses\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.UsesNode}\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.DataNodeContainere#getUses()}\r
+ * \r
+ * <dt>value\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.EnumTypeDefinition.EnumPair#getValue()}\r
+ * \r
+ * <dt>when\r
+ * <dd>{@link org.opendaylight.controller.yang.model.api.ConstraintDefinition#getWhenCondition()}\r
+ * \r
+ * <dt>yang-version\r
+ * \r
+ * <dt>yin-element\r
+ * <dd>\r
+ * \r
+ * \r
+ * \r
+ * \r
+ * <dt>add\r
+ * <dd>\r
+ * \r
+ * <dt>current\r
+ * <dd>\r
+ * \r
+ * <dt>delete\r
+ * <dd>\r
+ * \r
+ * <dt>deprecated\r
+ * <dd>\r
+ * \r
+ * <dt>false\r
+ * <dd>\r
+ * \r
+ * <dt>max\r
+ * <dd>\r
+ * \r
+ * <dt>min\r
+ * <dd>\r
+ * \r
+ * <dt>not-supported\r
+ * <dd>\r
+ * \r
+ * <dt>obsolete\r
+ * <dd>\r
+ * \r
+ * <dt>replace\r
+ * <dd>\r
+ * \r
+ * <dt>system\r
+ * <dd>\r
+ * \r
+ * <dt>true\r
+ * <dd>\r
+ * \r
+ * <dt>unbounded\r
+ * <dd>\r
+ * \r
+ * <dt>user\r
+ * <dd>\r
+ * </dl>\r
+ * \r
+ * \r
+ * <h3>YANG Base Type Mapping</h3>\r
+ * \r
+ * \r
+ * <dl>\r
+ * <dt>Integer built-in type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.IntegerTypeDefinition}\r
+ * \r
+ * <dt>Unsigned integer built-in type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition}\r
+ * \r
+ * <dt>Decimal64 built-ib type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.DecimalTypeDefinition}\r
+ * \r
+ * <dt>Boolean built-in type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.BooleanTypeDefinition}\r
+ * \r
+ * <dt>Enumeration built-in type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.EnumTypeDefinition}\r
+ * \r
+ * <dt>Bits Built-In Type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.BitsTypeDefinition}\r
+ * \r
+ * <dt>The binary Built-In Type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.BinaryTypeDefinition}\r
+ * \r
+ * <dt>The leafref Built-In Type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.LeafrefTypeDefinition}\r
+ * \r
+ * <dt>The identityref Built-In Type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.IdentityrefTypeDefinition}\r
+ * \r
+ * <dt>The empty Built-In Type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.EmptyTypeDefinition}\r
+ * \r
+ * <dt>The union Built-In Type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.UnionTypeDefinition}\r
+ * <dt>The instance-identifier Built-In Type\r
+ * <dd>{@link org.opendaylight.controller.model.api.type.InstanceIdentifierTypeDefinition}\r
+ * \r
+ * </dl>\r
+ */\r
+package org.opendaylight.controller.yang.model.api;\r
+\r
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang</artifactId>\r
+ <version>1.0</version>\r
+ </parent>\r
+ <artifactId>yang-model-util</artifactId>\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>yang-model-api</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ </dependencies>\r
+</project>\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public abstract class AbstractInteger implements IntegerTypeDefinition {\r
+\r
+ private final QName name;\r
+ private final SchemaPath path;\r
+\r
+ private final String description;\r
+ private final String reference;\r
+\r
+ private String units = "";\r
+ private final List<RangeConstraint> rangeStatements;\r
+\r
+ public AbstractInteger(final QName name, final String description,\r
+ final String reference) {\r
+ super();\r
+ this.name = name;\r
+ this.description = description;\r
+ this.reference = reference;\r
+ this.path = BaseTypes.schemaPath(name);\r
+\r
+ final List<? extends RangeConstraint> emptyContstraints = Collections\r
+ .emptyList();\r
+ this.rangeStatements = Collections.unmodifiableList(emptyContstraints);\r
+ }\r
+\r
+ public AbstractInteger(QName name, String description, String reference,\r
+ List<RangeConstraint> rangeStatements) {\r
+ super();\r
+ this.name = name;\r
+ this.description = description;\r
+ this.reference = reference;\r
+ this.rangeStatements = rangeStatements;\r
+ this.path = BaseTypes.schemaPath(name);\r
+ }\r
+\r
+ public AbstractInteger(QName name, String description, String reference,\r
+ String units) {\r
+ super();\r
+ this.name = name;\r
+ this.description = description;\r
+ this.reference = reference;\r
+ this.units = units;\r
+ this.path = BaseTypes.schemaPath(name);\r
+\r
+ final List<? extends RangeConstraint> emptyContstraints = Collections\r
+ .emptyList();\r
+ this.rangeStatements = Collections.unmodifiableList(emptyContstraints);\r
+ }\r
+\r
+ public AbstractInteger(QName name, String description, String reference,\r
+ String units, List<RangeConstraint> rangeStatements) {\r
+ super();\r
+ this.name = name;\r
+ this.description = description;\r
+ this.reference = reference;\r
+ this.units = units;\r
+ this.rangeStatements = rangeStatements;\r
+ this.path = BaseTypes.schemaPath(name);\r
+ }\r
+\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ @Override\r
+ public List<RangeConstraint> getRangeStatements() {\r
+ return rangeStatements;\r
+ }\r
+\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result\r
+ + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ AbstractInteger other = (AbstractInteger) obj;\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (name == null) {\r
+ if (other.name != null) {\r
+ return false;\r
+ }\r
+ } else if (!name.equals(other.name)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ if (rangeStatements == null) {\r
+ if (other.rangeStatements != null) {\r
+ return false;\r
+ }\r
+ } else if (!rangeStatements.equals(other.rangeStatements)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("AbstractInteger [name=");\r
+ builder.append(name);\r
+ builder.append(", path=");\r
+ builder.append(path);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", units=");\r
+ builder.append(units);\r
+ builder.append(", rangeStatements=");\r
+ builder.append(rangeStatements);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import org.opendaylight.controller.model.api.type.LengthConstraint;\r
+import org.opendaylight.controller.model.api.type.PatternConstraint;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+\r
+public final class BaseConstraints {\r
+\r
+ private BaseConstraints() {\r
+ }\r
+\r
+ public static LengthConstraint lengthConstraint(final long min,\r
+ final long max, final String description, final String reference) {\r
+ return new LengthConstraintImpl(min, max, description, reference);\r
+ }\r
+\r
+ public static RangeConstraint rangeConstraint(final long min,\r
+ final long max, final String description, final String reference) {\r
+ return new RangeConstraintImpl(min, max, description, reference);\r
+ }\r
+\r
+ public static PatternConstraint patternConstraint(final String pattern,\r
+ final String description, final String reference) {\r
+ return new PatternConstraintImpl(pattern, description, reference);\r
+ }\r
+\r
+ private static final class LengthConstraintImpl implements LengthConstraint {\r
+\r
+ private final long min;\r
+ private final long max;\r
+\r
+ private final String description;\r
+ private final String reference;\r
+\r
+ private final String errorAppTag;\r
+ private final String errorMessage;\r
+\r
+ public LengthConstraintImpl(long min, long max,\r
+ final String description, final String reference) {\r
+ super();\r
+ this.min = min;\r
+ this.max = max;\r
+ this.description = description;\r
+ this.reference = reference;\r
+\r
+ this.errorAppTag = "length-out-of-specified-bounds";\r
+ this.errorMessage = "The argument is out of bounds <" + min + ", "\r
+ + max + ">";\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ @Override\r
+ public String getErrorAppTag() {\r
+ return errorAppTag;\r
+ }\r
+\r
+ @Override\r
+ public String getErrorMessage() {\r
+ return errorMessage;\r
+ }\r
+\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ @Override\r
+ public Long getMin() {\r
+ return min;\r
+ }\r
+\r
+ @Override\r
+ public Long getMax() {\r
+ return max;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result\r
+ + ((errorAppTag == null) ? 0 : errorAppTag.hashCode());\r
+ result = prime * result\r
+ + ((errorMessage == null) ? 0 : errorMessage.hashCode());\r
+ result = prime * result + (int) (max ^ (max >>> 32));\r
+ result = prime * result + (int) (min ^ (min >>> 32));\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(final Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ final LengthConstraintImpl other = (LengthConstraintImpl) obj;\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (errorAppTag == null) {\r
+ if (other.errorAppTag != null) {\r
+ return false;\r
+ }\r
+ } else if (!errorAppTag.equals(other.errorAppTag)) {\r
+ return false;\r
+ }\r
+ if (errorMessage == null) {\r
+ if (other.errorMessage != null) {\r
+ return false;\r
+ }\r
+ } else if (!errorMessage.equals(other.errorMessage)) {\r
+ return false;\r
+ }\r
+ if (max != other.max) {\r
+ return false;\r
+ }\r
+ if (min != other.min) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("LengthConstraintImpl [min=");\r
+ builder.append(min);\r
+ builder.append(", max=");\r
+ builder.append(max);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", errorAppTag=");\r
+ builder.append(errorAppTag);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", errorMessage=");\r
+ builder.append(errorMessage);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+ }\r
+\r
+ private final static class RangeConstraintImpl implements RangeConstraint {\r
+ private final Long min;\r
+ private final Long max;\r
+\r
+ private final String description;\r
+ private final String reference;\r
+\r
+ private final String errorAppTag;\r
+ private final String errorMessage;\r
+\r
+ public RangeConstraintImpl(Long min, Long max, String description,\r
+ String reference) {\r
+ super();\r
+ this.min = min;\r
+ this.max = max;\r
+ this.description = description;\r
+ this.reference = reference;\r
+\r
+ this.errorAppTag = "range-out-of-specified-bounds";\r
+ this.errorMessage = "The argument is out of bounds <" + min + ", "\r
+ + max + ">";\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ @Override\r
+ public String getErrorAppTag() {\r
+ return errorAppTag;\r
+ }\r
+\r
+ @Override\r
+ public String getErrorMessage() {\r
+ return errorMessage;\r
+ }\r
+\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ @Override\r
+ public Long getMin() {\r
+ return min;\r
+ }\r
+\r
+ @Override\r
+ public Long getMax() {\r
+ return max;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result\r
+ + ((errorAppTag == null) ? 0 : errorAppTag.hashCode());\r
+ result = prime * result\r
+ + ((errorMessage == null) ? 0 : errorMessage.hashCode());\r
+ result = prime * result + ((max == null) ? 0 : max.hashCode());\r
+ result = prime * result + ((min == null) ? 0 : min.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(final Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ final RangeConstraintImpl other = (RangeConstraintImpl) obj;\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (errorAppTag == null) {\r
+ if (other.errorAppTag != null) {\r
+ return false;\r
+ }\r
+ } else if (!errorAppTag.equals(other.errorAppTag)) {\r
+ return false;\r
+ }\r
+ if (errorMessage == null) {\r
+ if (other.errorMessage != null) {\r
+ return false;\r
+ }\r
+ } else if (!errorMessage.equals(other.errorMessage)) {\r
+ return false;\r
+ }\r
+ if (max == null) {\r
+ if (other.max != null) {\r
+ return false;\r
+ }\r
+ } else if (!max.equals(other.max)) {\r
+ return false;\r
+ }\r
+ if (min == null) {\r
+ if (other.min != null) {\r
+ return false;\r
+ }\r
+ } else if (!min.equals(other.min)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ final StringBuilder builder = new StringBuilder();\r
+ builder.append("RangeConstraintImpl [min=");\r
+ builder.append(min);\r
+ builder.append(", max=");\r
+ builder.append(max);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", errorAppTag=");\r
+ builder.append(errorAppTag);\r
+ builder.append(", errorMessage=");\r
+ builder.append(errorMessage);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+ }\r
+\r
+ private final static class PatternConstraintImpl implements\r
+ PatternConstraint {\r
+\r
+ private final String regex;\r
+ private final String description;\r
+ private final String reference;\r
+\r
+ private final String errorAppTag;\r
+ private final String errorMessage;\r
+\r
+ public PatternConstraintImpl(final String regex,\r
+ final String description, final String reference) {\r
+ super();\r
+ this.regex = regex;\r
+ this.description = description;\r
+ this.reference = reference;\r
+\r
+ errorAppTag = "invalid-regular-expression";\r
+ // TODO: add erro message\r
+ errorMessage = "";\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ @Override\r
+ public String getErrorAppTag() {\r
+ return errorAppTag;\r
+ }\r
+\r
+ @Override\r
+ public String getErrorMessage() {\r
+ return errorMessage;\r
+ }\r
+\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ @Override\r
+ public String getRegularExpression() {\r
+ return regex;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result\r
+ + ((errorAppTag == null) ? 0 : errorAppTag.hashCode());\r
+ result = prime * result\r
+ + ((errorMessage == null) ? 0 : errorMessage.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((regex == null) ? 0 : regex.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(final Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ final PatternConstraintImpl other = (PatternConstraintImpl) obj;\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (errorAppTag == null) {\r
+ if (other.errorAppTag != null) {\r
+ return false;\r
+ }\r
+ } else if (!errorAppTag.equals(other.errorAppTag)) {\r
+ return false;\r
+ }\r
+ if (errorMessage == null) {\r
+ if (other.errorMessage != null) {\r
+ return false;\r
+ }\r
+ } else if (!errorMessage.equals(other.errorMessage)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (regex == null) {\r
+ if (other.regex != null) {\r
+ return false;\r
+ }\r
+ } else if (!regex.equals(other.regex)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("PatternConstraintImpl [regex=");\r
+ builder.append(regex);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", errorAppTag=");\r
+ builder.append(errorAppTag);\r
+ builder.append(", errorMessage=");\r
+ builder.append(errorMessage);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.net.URI;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+\r
+public final class BaseTypes {\r
+\r
+ private BaseTypes() {\r
+ }\r
+\r
+ public static final URI BaseTypesNamespace = URI\r
+ .create("urn:ietf:params:xml:ns:yang:1");\r
+\r
+ public static final QName constructQName(final String typeName) {\r
+ return new QName(BaseTypesNamespace, typeName);\r
+ }\r
+\r
+ public static final SchemaPath schemaPath(final QName typeName) {\r
+ final List<QName> pathList = new ArrayList<QName>();\r
+ pathList.add(typeName);\r
+ return new SchemaPath(pathList, true);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.BinaryTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.LengthConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class BinaryType implements BinaryTypeDefinition {\r
+\r
+ private final QName name = BaseTypes.constructQName("binary");\r
+ private final SchemaPath path = BaseTypes.schemaPath(name);\r
+ private final String description = "";\r
+ private final String reference = "";\r
+\r
+ private List<Byte> bytes;\r
+ private final LengthConstraint lengthConstraint;\r
+ private String units = "";\r
+\r
+ public BinaryType() {\r
+ super();\r
+\r
+ lengthConstraint = BaseConstraints.lengthConstraint(0L, Long.MAX_VALUE,\r
+ null, null);\r
+ bytes = Collections.emptyList();\r
+ bytes = Collections.unmodifiableList(bytes);\r
+ }\r
+\r
+ public BinaryType(final List<Byte> bytes,\r
+ final LengthConstraint lengthConstraint, final String units) {\r
+ super();\r
+ this.bytes = bytes;\r
+ this.lengthConstraint = lengthConstraint;\r
+ this.units = units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public BinaryTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
+ */\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return bytes;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
+ */\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
+ */\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
+ */\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
+ */\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
+ */\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.base.type.api.BinaryTypeDefinition#getLengthConstraint\r
+ * ()\r
+ */\r
+ @Override\r
+ public LengthConstraint getLengthConstraint() {\r
+ return lengthConstraint;\r
+ }\r
+\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + ((bytes == null) ? 0 : bytes.hashCode());\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime\r
+ * result\r
+ + ((lengthConstraint == null) ? 0 : lengthConstraint.hashCode());\r
+ result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ BinaryType other = (BinaryType) obj;\r
+ if (bytes == null) {\r
+ if (other.bytes != null) {\r
+ return false;\r
+ }\r
+ } else if (!bytes.equals(other.bytes)) {\r
+ return false;\r
+ }\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (lengthConstraint == null) {\r
+ if (other.lengthConstraint != null) {\r
+ return false;\r
+ }\r
+ } else if (!lengthConstraint.equals(other.lengthConstraint)) {\r
+ return false;\r
+ }\r
+ if (name == null) {\r
+ if (other.name != null) {\r
+ return false;\r
+ }\r
+ } else if (!name.equals(other.name)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("BinaryType [name=");\r
+ builder.append(name);\r
+ builder.append(", path=");\r
+ builder.append(path);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", bytes=");\r
+ builder.append(bytes);\r
+ builder.append(", lengthConstraint=");\r
+ builder.append(lengthConstraint);\r
+ builder.append(", units=");\r
+ builder.append(units);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.BitsTypeDefinition;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class BitsType implements BitsTypeDefinition {\r
+\r
+ private final QName name = BaseTypes.constructQName("bits");\r
+ private final SchemaPath path = BaseTypes.schemaPath(name);\r
+ private final String description = "";\r
+ private final String reference = "";\r
+\r
+ private final List<Bit> bits;\r
+ private String units = "";\r
+\r
+ /**\r
+ * Default constructor. <br>\r
+ * Instantiates Bits type as empty bits list.\r
+ * \r
+ */\r
+ public BitsType() {\r
+ super();\r
+ bits = Collections.emptyList();\r
+ }\r
+\r
+ /**\r
+ * Overloaded constructor with explicit definition of bits assigned to\r
+ * BitsType.\r
+ * \r
+ * @param bits\r
+ * The bits assigned for Bits Type\r
+ */\r
+ public BitsType(final List<Bit> bits) {\r
+ super();\r
+ this.bits = Collections.unmodifiableList(bits);\r
+ this.units = "";\r
+ }\r
+\r
+ public BitsType(List<Bit> bits, String units) {\r
+ super();\r
+ this.bits = Collections.unmodifiableList(bits);\r
+ ;\r
+ this.units = units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public BitsTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
+ */\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return bits;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
+ */\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
+ */\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
+ */\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
+ */\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
+ */\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ @Override\r
+ public List<Bit> getBits() {\r
+ return bits;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + ((bits == null) ? 0 : bits.hashCode());\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ BitsType other = (BitsType) obj;\r
+ if (bits == null) {\r
+ if (other.bits != null) {\r
+ return false;\r
+ }\r
+ } else if (!bits.equals(other.bits)) {\r
+ return false;\r
+ }\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (name == null) {\r
+ if (other.name != null) {\r
+ return false;\r
+ }\r
+ } else if (!name.equals(other.name)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("BitsType [name=");\r
+ builder.append(name);\r
+ builder.append(", path=");\r
+ builder.append(path);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", bits=");\r
+ builder.append(bits);\r
+ builder.append(", units=");\r
+ builder.append(units);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.BooleanTypeDefinition;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class BooleanType implements BooleanTypeDefinition {\r
+\r
+ private final QName name = BaseTypes.constructQName("boolean");\r
+ private final SchemaPath path = BaseTypes.schemaPath(name);\r
+ private final String description = "";\r
+ private final String reference = "";\r
+\r
+ private final Boolean defaultValue;\r
+ private String units = "";\r
+\r
+ /**\r
+ * Default constructor with default value set to "false".\r
+ */\r
+ public BooleanType() {\r
+ super();\r
+ defaultValue = false;\r
+ }\r
+\r
+ /**\r
+ * \r
+ * \r
+ * @param defaultValue\r
+ */\r
+ public BooleanType(final Boolean defaultValue) {\r
+ super();\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ /**\r
+ * \r
+ * \r
+ * @param defaultValue\r
+ * @param units\r
+ */\r
+ public BooleanType(final Boolean defaultValue, final String units) {\r
+ super();\r
+ this.defaultValue = defaultValue;\r
+ this.units = units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public BooleanTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
+ */\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
+ */\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
+ */\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
+ */\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
+ */\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
+ */\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ BooleanType other = (BooleanType) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (name == null) {\r
+ if (other.name != null) {\r
+ return false;\r
+ }\r
+ } else if (!name.equals(other.name)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("BooleanType [name=");\r
+ builder.append(name);\r
+ builder.append(", path=");\r
+ builder.append(path);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", defaultValue=");\r
+ builder.append(defaultValue);\r
+ builder.append(", units=");\r
+ builder.append(units);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.math.BigDecimal;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.DecimalTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class Decimal64 implements DecimalTypeDefinition {\r
+\r
+ private final QName name = BaseTypes.constructQName("decimal64");\r
+ private final SchemaPath path;\r
+ private String units = "";\r
+ private BigDecimal defaultValue = null;\r
+\r
+ private final String description = "The decimal64 type represents a subset of the real numbers, which can "\r
+ + "be represented by decimal numerals. The value space of decimal64 is the set of numbers that can "\r
+ + "be obtained by multiplying a 64-bit signed integer by a negative power of ten, i.e., expressible as "\r
+ + "'i x 10^-n' where i is an integer64 and n is an integer between 1 and 18, inclusively.";\r
+\r
+ private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.3";\r
+\r
+ private final List<RangeConstraint> rangeStatements;\r
+ private final Integer fractionDigits;\r
+\r
+ public Decimal64(final Integer fractionDigits) {\r
+ super();\r
+ this.fractionDigits = fractionDigits;\r
+ rangeStatements = new ArrayList<RangeConstraint>();\r
+ this.path = BaseTypes.schemaPath(name);\r
+ }\r
+\r
+ public Decimal64(final List<RangeConstraint> rangeStatements,\r
+ Integer fractionDigits) {\r
+ super();\r
+ this.rangeStatements = rangeStatements;\r
+ this.fractionDigits = fractionDigits;\r
+ this.path = BaseTypes.schemaPath(name);\r
+ }\r
+\r
+ public Decimal64(final String units, final BigDecimal defaultValue,\r
+ final List<RangeConstraint> rangeStatements,\r
+ final Integer fractionDigits) {\r
+ super();\r
+ this.units = units;\r
+ this.defaultValue = defaultValue;\r
+ this.rangeStatements = rangeStatements;\r
+ this.fractionDigits = fractionDigits;\r
+ this.path = BaseTypes.schemaPath(name);\r
+ }\r
+\r
+ @Override\r
+ public DecimalTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ @Override\r
+ public List<RangeConstraint> getRangeStatements() {\r
+ return rangeStatements;\r
+ }\r
+\r
+ @Override\r
+ public Integer getFractionDigits() {\r
+ return fractionDigits;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return Decimal64.class.getSimpleName() + "[qname=" + name\r
+ + ", fractionDigits=" + fractionDigits + "]";\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.EnumTypeDefinition;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class EnumerationType implements EnumTypeDefinition {\r
+\r
+ private final QName name = BaseTypes.constructQName("enumeration");\r
+ private final SchemaPath path = BaseTypes.schemaPath(name);\r
+ private final String description = "The enumeration built-in type represents values from a set of assigned names.";\r
+ private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.6";\r
+\r
+ private final List<EnumPair> defaultEnum;\r
+ private final List<EnumPair> enums;\r
+ private String units = "";\r
+\r
+ public EnumerationType(final List<EnumPair> enums) {\r
+ super();\r
+ this.enums = enums;\r
+\r
+ defaultEnum = Collections.emptyList();\r
+ }\r
+\r
+ public EnumerationType(final List<EnumPair> defaultEnum,\r
+ final List<EnumPair> enums, final String units) {\r
+ super();\r
+ this.defaultEnum = defaultEnum;\r
+ this.enums = enums;\r
+ this.units = units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public EnumTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
+ */\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultEnum;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
+ */\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
+ */\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
+ */\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
+ */\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
+ */\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.base.type.api.EnumTypeDefinition#getValues()\r
+ */\r
+ @Override\r
+ public List<EnumPair> getValues() {\r
+ return enums;\r
+ }\r
+\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((defaultEnum == null) ? 0 : defaultEnum.hashCode());\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result + ((enums == null) ? 0 : enums.hashCode());\r
+ result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ EnumerationType other = (EnumerationType) obj;\r
+ if (defaultEnum == null) {\r
+ if (other.defaultEnum != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultEnum.equals(other.defaultEnum)) {\r
+ return false;\r
+ }\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (enums == null) {\r
+ if (other.enums != null) {\r
+ return false;\r
+ }\r
+ } else if (!enums.equals(other.enums)) {\r
+ return false;\r
+ }\r
+ if (name == null) {\r
+ if (other.name != null) {\r
+ return false;\r
+ }\r
+ } else if (!name.equals(other.name)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("EnumerationType [name=");\r
+ builder.append(name);\r
+ builder.append(", path=");\r
+ builder.append(path);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", defaultEnum=");\r
+ builder.append(defaultEnum);\r
+ builder.append(", enums=");\r
+ builder.append(enums);\r
+ builder.append(", units=");\r
+ builder.append(units);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public class ExtendedType implements TypeDefinition {\r
+\r
+ private final QName typeName;\r
+ private final TypeDefinition<?> baseType;\r
+ private final SchemaPath path;\r
+ private final String description;\r
+ private final String reference;\r
+ private final List<ExtensionDefinition> extensions;\r
+\r
+ private Status status;\r
+ private String units;\r
+ private Object defaultValue;\r
+\r
+ public static class Builder {\r
+ private final QName typeName;\r
+ private final TypeDefinition<?> baseType;\r
+\r
+ private final SchemaPath path;\r
+ private final String description;\r
+ private final String reference;\r
+\r
+ private List<ExtensionDefinition> extensions = Collections.emptyList();;\r
+ private Status status = Status.CURRENT;\r
+ private String units = "";\r
+ private Object defaultValue = null;\r
+\r
+ public Builder(final QName typeName, TypeDefinition<?> baseType,\r
+ final String description, final String reference) {\r
+ this.typeName = typeName;\r
+ this.baseType = baseType;\r
+ this.path = BaseTypes.schemaPath(typeName);\r
+ this.description = description;\r
+ this.reference = reference;\r
+ }\r
+\r
+ public Builder status(Status status) {\r
+ this.status = status;\r
+ return this;\r
+ }\r
+\r
+ public Builder units(String units) {\r
+ this.units = units;\r
+ return this;\r
+ }\r
+\r
+ public Builder defaultValue(final Object defaultValue) {\r
+ this.defaultValue = defaultValue;\r
+ return this;\r
+ }\r
+\r
+ public Builder extensions(final List<ExtensionDefinition> extensions) {\r
+ this.extensions = extensions;\r
+ return this;\r
+ }\r
+\r
+ public ExtendedType build() {\r
+ return new ExtendedType(this);\r
+ }\r
+ }\r
+\r
+ private ExtendedType(Builder builder) {\r
+ this.typeName = builder.typeName;\r
+ this.baseType = builder.baseType;\r
+ this.path = builder.path;\r
+ this.description = builder.description;\r
+ this.reference = builder.reference;\r
+ this.extensions = builder.extensions;\r
+ this.status = builder.status;\r
+ this.units = builder.units;\r
+ this.defaultValue = builder.defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public TypeDefinition<?> getBaseType() {\r
+ return baseType;\r
+ }\r
+\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public QName getQName() {\r
+ return typeName;\r
+ }\r
+\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ @Override\r
+ public Status getStatus() {\r
+ return status;\r
+ }\r
+\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return extensions;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((baseType == null) ? 0 : baseType.hashCode());\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result\r
+ + ((extensions == null) ? 0 : extensions.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((status == null) ? 0 : status.hashCode());\r
+ result = prime * result\r
+ + ((typeName == null) ? 0 : typeName.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ ExtendedType other = (ExtendedType) obj;\r
+ if (baseType == null) {\r
+ if (other.baseType != null) {\r
+ return false;\r
+ }\r
+ } else if (!baseType.equals(other.baseType)) {\r
+ return false;\r
+ }\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (extensions == null) {\r
+ if (other.extensions != null) {\r
+ return false;\r
+ }\r
+ } else if (!extensions.equals(other.extensions)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (status != other.status) {\r
+ return false;\r
+ }\r
+ if (typeName == null) {\r
+ if (other.typeName != null) {\r
+ return false;\r
+ }\r
+ } else if (!typeName.equals(other.typeName)) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder2 = new StringBuilder();\r
+ builder2.append("ExtendedType [typeName=");\r
+ builder2.append(typeName);\r
+ builder2.append(", baseType=");\r
+ builder2.append(baseType);\r
+ builder2.append(", path=");\r
+ builder2.append(path);\r
+ builder2.append(", description=");\r
+ builder2.append(description);\r
+ builder2.append(", reference=");\r
+ builder2.append(reference);\r
+ builder2.append(", extensions=");\r
+ builder2.append(extensions);\r
+ builder2.append(", status=");\r
+ builder2.append(status);\r
+ builder2.append(", units=");\r
+ builder2.append(units);\r
+ builder2.append(", defaultValue=");\r
+ builder2.append(defaultValue);\r
+ builder2.append("]");\r
+ return builder2.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IdentityTypeDefinition;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class IdentityType implements IdentityTypeDefinition {\r
+\r
+ private final QName name = BaseTypes.constructQName("identity");\r
+ private final SchemaPath path = BaseTypes.schemaPath(name);\r
+ private final String description = "";\r
+ private final String reference = "";\r
+\r
+ private String units = "";\r
+ private final QName identityName;\r
+\r
+ public IdentityType(QName identityName) {\r
+ super();\r
+ this.identityName = identityName;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public IdentityTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
+ */\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
+ */\r
+ @Override\r
+ public QName getQName() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
+ */\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
+ */\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
+ */\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
+ */\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.base.type.api.IdentityTypeDefinition#getIdentityName\r
+ * ()\r
+ */\r
+ @Override\r
+ public QName getIdentityName() {\r
+ return identityName;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result\r
+ + ((identityName == null) ? 0 : identityName.hashCode());\r
+ result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ IdentityType other = (IdentityType) obj;\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (identityName == null) {\r
+ if (other.identityName != null) {\r
+ return false;\r
+ }\r
+ } else if (!identityName.equals(other.identityName)) {\r
+ return false;\r
+ }\r
+ if (name == null) {\r
+ if (other.name != null) {\r
+ return false;\r
+ }\r
+ } else if (!name.equals(other.name)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("IdentityType [name=");\r
+ builder.append(name);\r
+ builder.append(", path=");\r
+ builder.append(path);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", units=");\r
+ builder.append(units);\r
+ builder.append(", identityName=");\r
+ builder.append(identityName);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IdentityTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.IdentityrefTypeDefinition;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class Identityref implements IdentityrefTypeDefinition {\r
+\r
+ private final QName name = BaseTypes.constructQName("identityref");\r
+ private final SchemaPath path = BaseTypes.schemaPath(name);\r
+ private final String description = "";\r
+ private final String reference = "";\r
+\r
+ private final IdentityTypeDefinition identity;\r
+\r
+ private String units = "";\r
+\r
+ public Identityref(IdentityTypeDefinition identity) {\r
+ super();\r
+ this.identity = identity;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public IdentityTypeDefinition getBaseType() {\r
+ return identity;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
+ */\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return identity;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
+ */\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
+ */\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
+ */\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
+ */\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
+ */\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.base.type.api.IdentityrefTypeDefinition#getIdentityName\r
+ * ()\r
+ */\r
+ @Override\r
+ public IdentityTypeDefinition getIdentity() {\r
+ return identity;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result\r
+ + ((identity == null) ? 0 : identity.hashCode());\r
+ result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Identityref other = (Identityref) obj;\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (identity == null) {\r
+ if (other.identity != null) {\r
+ return false;\r
+ }\r
+ } else if (!identity.equals(other.identity)) {\r
+ return false;\r
+ }\r
+ if (name == null) {\r
+ if (other.name != null) {\r
+ return false;\r
+ }\r
+ } else if (!name.equals(other.name)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("IdentityrefType [name=");\r
+ builder.append(name);\r
+ builder.append(", path=");\r
+ builder.append(path);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", identity=");\r
+ builder.append(identity);\r
+ builder.append(", units=");\r
+ builder.append(units);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.InstanceIdentifierTypeDefinition;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {\r
+\r
+ private static final QName name = BaseTypes\r
+ .constructQName("instance-identifier");\r
+ private static final String description = "";\r
+ private static final String reference = "";\r
+\r
+ private final transient SchemaPath path = BaseTypes.schemaPath(name);\r
+ private final RevisionAwareXPath xpath;\r
+ private final String units = "";\r
+\r
+ private final boolean requireInstance;\r
+\r
+ public InstanceIdentifier(RevisionAwareXPath xpath, boolean requireInstance) {\r
+ super();\r
+ this.xpath = xpath;\r
+ this.requireInstance = requireInstance;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public InstanceIdentifierTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
+ */\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return xpath;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
+ */\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
+ */\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
+ */\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
+ */\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
+ */\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes()\r
+ */\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition#\r
+ * getPathStatement()\r
+ */\r
+ @Override\r
+ public RevisionAwareXPath getPathStatement() {\r
+ return xpath;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition#\r
+ * requireInstance()\r
+ */\r
+ @Override\r
+ public boolean requireInstance() {\r
+ return requireInstance;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public class Int16 extends AbstractInteger {\r
+\r
+ private static final QName name = BaseTypes.constructQName("int16");\r
+ private Short defaultValue = null;\r
+ private static final String description = "";\r
+ private static final String reference = "";\r
+\r
+ public Int16() {\r
+ super(name, description, reference);\r
+ }\r
+\r
+ public Int16(final Short defaultValue) {\r
+ super(name, description, reference);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int16(final List<RangeConstraint> rangeStatements,\r
+ final Short defaultValue) {\r
+ super(name, description, reference, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int16(final String units, final Short defaultValue) {\r
+ super(name, description, reference, units);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int16(final List<RangeConstraint> rangeStatements,\r
+ final String units, final Short defaultValue) {\r
+ super(name, description, reference, units, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public IntegerTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = super.hashCode();\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (!super.equals(obj)) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Int16 other = (Int16) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("Int16 [defaultValue=");\r
+ builder.append(defaultValue);\r
+ builder.append(", AbstractInteger=");\r
+ builder.append(super.toString());\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public class Int32 extends AbstractInteger {\r
+\r
+ private static final QName name = BaseTypes.constructQName("int32");\r
+ private Integer defaultValue = null;\r
+ private static final String description = "";\r
+ private static final String reference = "";\r
+\r
+ public Int32() {\r
+ super(name, description, reference);\r
+ }\r
+\r
+ public Int32(final Integer defaultValue) {\r
+ super(name, description, reference);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int32(final List<RangeConstraint> rangeStatements,\r
+ final Integer defaultValue) {\r
+ super(name, description, reference, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int32(final String units, final Integer defaultValue) {\r
+ super(name, description, reference, units);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int32(final List<RangeConstraint> rangeStatements,\r
+ final String units, final Integer defaultValue) {\r
+ super(name, description, reference, units, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public IntegerTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = super.hashCode();\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (!super.equals(obj)) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Int32 other = (Int32) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("Int32 [defaultValue=");\r
+ builder.append(defaultValue);\r
+ builder.append(", AbstractInteger=");\r
+ builder.append(super.toString());\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public class Int64 extends AbstractInteger {\r
+\r
+ private static final QName name = BaseTypes.constructQName("int64");\r
+ private Long defaultValue = null;\r
+ private static final String description = "";\r
+ private static final String reference = "";\r
+\r
+ public Int64() {\r
+ super(name, description, reference);\r
+ }\r
+\r
+ public Int64(final Long defaultValue) {\r
+ super(name, description, reference);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int64(final List<RangeConstraint> rangeStatements,\r
+ final Long defaultValue) {\r
+ super(name, description, reference, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int64(final String units, final Long defaultValue) {\r
+ super(name, description, reference, units);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int64(final List<RangeConstraint> rangeStatements,\r
+ final String units, final Long defaultValue) {\r
+ super(name, description, reference, units, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public IntegerTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = super.hashCode();\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (!super.equals(obj)) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Int64 other = (Int64) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("Int64 [defaultValue=");\r
+ builder.append(defaultValue);\r
+ builder.append(", AbstractInteger=");\r
+ builder.append(super.toString());\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public class Int8 extends AbstractInteger {\r
+\r
+ private static final QName name = BaseTypes.constructQName("int8");\r
+ private Byte defaultValue = null;\r
+ private static final String description = "";\r
+ private static final String reference = "";\r
+\r
+ public Int8() {\r
+ super(name, description, reference);\r
+ }\r
+\r
+ public Int8(final Byte defaultValue) {\r
+ super(name, description, reference);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int8(final List<RangeConstraint> rangeStatements,\r
+ final Byte defaultValue) {\r
+ super(name, description, reference, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int8(final String units, final Byte defaultValue) {\r
+ super(name, description, reference, units);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Int8(final List<RangeConstraint> rangeStatements,\r
+ final String units, final Byte defaultValue) {\r
+ super(name, description, reference, units, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public IntegerTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = super.hashCode();\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (!super.equals(obj)) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Int8 other = (Int8) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("Int8 [defaultValue=");\r
+ builder.append(defaultValue);\r
+ builder.append(", AbstractInteger=");\r
+ builder.append(super.toString());\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.LeafrefTypeDefinition;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class Leafref implements LeafrefTypeDefinition {\r
+ private static final QName name = BaseTypes.constructQName("leafref");\r
+ private static final String description = "";\r
+ private static final String reference = "";\r
+ private final SchemaPath path = BaseTypes.schemaPath(name);\r
+ private final RevisionAwareXPath xpath;\r
+ private final String units = "";\r
+\r
+ public Leafref(RevisionAwareXPath xpath) {\r
+ super();\r
+ this.xpath = xpath;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public LeafrefTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
+ */\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
+ */\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
+ */\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
+ */\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
+ */\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
+ */\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes()\r
+ */\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition#getPathStatement()\r
+ */\r
+ @Override\r
+ public RevisionAwareXPath getPathStatement() {\r
+ return xpath;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Leafref other = (Leafref) obj;\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ if (xpath == null) {\r
+ if (other.xpath != null) {\r
+ return false;\r
+ }\r
+ } else if (!xpath.equals(other.xpath)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("Leafref [path=");\r
+ builder.append(path);\r
+ builder.append(", xpath=");\r
+ builder.append(xpath);\r
+ builder.append(", units=");\r
+ builder.append(units);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.LengthConstraint;\r
+import org.opendaylight.controller.model.api.type.PatternConstraint;\r
+import org.opendaylight.controller.model.api.type.StringTypeDefinition;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class StringType implements StringTypeDefinition {\r
+\r
+ private final QName name = BaseTypes.constructQName("string");;\r
+ private final SchemaPath path;\r
+ private String defaultValue = "";\r
+ private final String description = "";\r
+ private final String reference = "";\r
+ private final List<LengthConstraint> lengthStatements;\r
+ private final List<PatternConstraint> patterns;\r
+ private String units = "";\r
+\r
+ public StringType() {\r
+ super();\r
+ path = BaseTypes.schemaPath(name);\r
+ this.lengthStatements = Collections.emptyList();\r
+ this.patterns = Collections.emptyList();\r
+ }\r
+\r
+ public StringType(List<LengthConstraint> lengthStatements,\r
+ List<PatternConstraint> patterns) {\r
+ super();\r
+ path = BaseTypes.schemaPath(name);\r
+ this.lengthStatements = Collections.unmodifiableList(lengthStatements);\r
+ this.patterns = Collections.unmodifiableList(patterns);\r
+ }\r
+\r
+ public StringType(final String defaultValue,\r
+ final List<LengthConstraint> lengthStatements,\r
+ final List<PatternConstraint> patterns, final String units) {\r
+ super();\r
+ path = BaseTypes.schemaPath(name);\r
+ this.defaultValue = defaultValue;\r
+ this.lengthStatements = lengthStatements;\r
+ this.patterns = patterns;\r
+ this.units = units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public StringTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
+ */\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
+ */\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
+ */\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
+ */\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
+ */\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
+ */\r
+ @Override\r
+ public Status getStatus() {\r
+ return Status.CURRENT;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * com.csico.yang.model.base.type.api.StringTypeDefinition#getLengthStatements\r
+ * ()\r
+ */\r
+ @Override\r
+ public List<LengthConstraint> getLengthStatements() {\r
+ return lengthStatements;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * com.csico.yang.model.base.type.api.StringTypeDefinition#getPatterns()\r
+ */\r
+ @Override\r
+ public List<PatternConstraint> getPatterns() {\r
+ return patterns;\r
+ }\r
+\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime\r
+ * result\r
+ + ((lengthStatements == null) ? 0 : lengthStatements.hashCode());\r
+ result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result\r
+ + ((patterns == null) ? 0 : patterns.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ StringType other = (StringType) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (lengthStatements == null) {\r
+ if (other.lengthStatements != null) {\r
+ return false;\r
+ }\r
+ } else if (!lengthStatements.equals(other.lengthStatements)) {\r
+ return false;\r
+ }\r
+ if (name == null) {\r
+ if (other.name != null) {\r
+ return false;\r
+ }\r
+ } else if (!name.equals(other.name)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if ((path != null) && (other.path != null)) {\r
+ if (!path.getPath().equals(other.path.getPath())) {\r
+ return false;\r
+ }\r
+ }\r
+ if (patterns == null) {\r
+ if (other.patterns != null) {\r
+ return false;\r
+ }\r
+ } else if (!patterns.equals(other.patterns)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("StringType [name=");\r
+ builder.append(name);\r
+ builder.append(", path=");\r
+ builder.append(path);\r
+ builder.append(", defaultValue=");\r
+ builder.append(defaultValue);\r
+ builder.append(", description=");\r
+ builder.append(description);\r
+ builder.append(", reference=");\r
+ builder.append(reference);\r
+ builder.append(", lengthStatements=");\r
+ builder.append(lengthStatements);\r
+ builder.append(", patterns=");\r
+ builder.append(patterns);\r
+ builder.append(", units=");\r
+ builder.append(units);\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public class Uint16 extends AbstractInteger {\r
+\r
+ private static final QName name = BaseTypes.constructQName("uint16");\r
+ private Integer defaultValue = null;\r
+ private static final String description = "";\r
+ private static final String reference = "";\r
+\r
+ public Uint16() {\r
+ super(name, description, reference);\r
+ }\r
+\r
+ public Uint16(final Integer defaultValue) {\r
+ super(name, description, reference);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Uint16(final List<RangeConstraint> rangeStatements,\r
+ final Integer defaultValue) {\r
+ super(name, description, reference, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Uint16(final String units, final Integer defaultValue) {\r
+ super(name, description, reference, units);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public IntegerTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = super.hashCode();\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (!super.equals(obj)) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Uint16 other = (Uint16) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("Uint16 [defaultValue=");\r
+ builder.append(defaultValue);\r
+ builder.append(", AbstractInteger=");\r
+ builder.append(super.toString());\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public class Uint32 extends AbstractInteger {\r
+\r
+ private static final QName name = BaseTypes.constructQName("uint32");\r
+ private Long defaultValue = null;\r
+ private static final String description = "";\r
+ private static final String reference = "";\r
+\r
+ public Uint32() {\r
+ super(name, description, reference);\r
+ }\r
+\r
+ public Uint32(final Long defaultValue) {\r
+ super(name, description, reference);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Uint32(final List<RangeConstraint> rangeStatements,\r
+ final Long defaultValue) {\r
+ super(name, description, reference, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Uint32(final String units, final Long defaultValue) {\r
+ super(name, description, reference, units);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public IntegerTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = super.hashCode();\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (!super.equals(obj)) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Uint32 other = (Uint32) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("Uint32 [defaultValue=");\r
+ builder.append(defaultValue);\r
+ builder.append(", AbstractInteger=");\r
+ builder.append(super.toString());\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.math.BigInteger;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public class Uint64 extends AbstractInteger {\r
+\r
+ private static final QName name = BaseTypes.constructQName("uint32");\r
+ private BigInteger defaultValue = null;\r
+ private static final String description = "";\r
+ private static final String reference = "";\r
+\r
+ public Uint64() {\r
+ super(name, description, reference);\r
+ }\r
+\r
+ public Uint64(final BigInteger defaultValue) {\r
+ super(name, description, reference);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Uint64(final List<RangeConstraint> rangeStatements,\r
+ final BigInteger defaultValue) {\r
+ super(name, description, reference, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Uint64(final String units, final BigInteger defaultValue) {\r
+ super(name, description, reference, units);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public IntegerTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = super.hashCode();\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (!super.equals(obj)) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Uint64 other = (Uint64) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("Uint64 [defaultValue=");\r
+ builder.append(defaultValue);\r
+ builder.append(", AbstractInteger=");\r
+ builder.append(super.toString());\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+public class Uint8 extends AbstractInteger {\r
+\r
+ private static final QName name = BaseTypes.constructQName("uint8");\r
+ private Short defaultValue = null;\r
+ private static final String description = "";\r
+ private static final String reference = "";\r
+\r
+ public Uint8() {\r
+ super(name, description, reference);\r
+ }\r
+\r
+ public Uint8(final Short defaultValue) {\r
+ super(name, description, reference);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Uint8(final List<RangeConstraint> rangeStatements,\r
+ final Short defaultValue) {\r
+ super(name, description, reference, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Uint8(final String units, final Short defaultValue) {\r
+ super(name, description, reference, units);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public Uint8(final List<RangeConstraint> rangeStatements,\r
+ final String units, final Short defaultValue) {\r
+ super(name, description, reference, units, rangeStatements);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public IntegerTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = super.hashCode();\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (!super.equals(obj)) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Uint8 other = (Uint8) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("Uint8 [defaultValue=");\r
+ builder.append(defaultValue);\r
+ builder.append(", AbstractInteger=");\r
+ builder.append(super.toString());\r
+ builder.append("]");\r
+ return builder.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.opendaylight.controller.model.api.type.LengthConstraint;\r
+import org.opendaylight.controller.model.api.type.PatternConstraint;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.model.api.type.UnknownTypeDefinition;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+\r
+public class UnknownType implements UnknownTypeDefinition {\r
+\r
+ private final QName name;\r
+ private final SchemaPath path;\r
+ private final String description;\r
+ private final String reference;\r
+\r
+ private final List<LengthConstraint> lengthStatements;\r
+ private final List<PatternConstraint> patterns;\r
+ private final List<RangeConstraint> rangeStatements;\r
+ private final List<ExtensionDefinition> extensions;\r
+ private final LengthConstraint lengthConstraint;\r
+\r
+ private final Status status;\r
+ private final String units;\r
+ private final Object defaultValue;\r
+\r
+ public static class Builder {\r
+\r
+ private final QName name;\r
+ private final SchemaPath path;\r
+ private String description;\r
+ private String reference;\r
+\r
+ private List<LengthConstraint> lengthStatements = Collections\r
+ .emptyList();\r
+ private List<PatternConstraint> patterns = Collections.emptyList();\r
+ private List<RangeConstraint> rangeStatements = Collections.emptyList();\r
+ private List<ExtensionDefinition> extensions = Collections.emptyList();\r
+ private LengthConstraint lengthConstraint = null;\r
+\r
+ private Status status = Status.CURRENT;\r
+ private String units = "";\r
+ private Object defaultValue = null;\r
+\r
+ public Builder(final QName name, final String description,\r
+ final String reference) {\r
+ this.name = name;\r
+ this.path = BaseTypes.schemaPath(name);\r
+ this.description = description;\r
+ this.reference = reference;\r
+ }\r
+\r
+ public Builder(final QName name) {\r
+ this.name = name;\r
+ this.path = BaseTypes.schemaPath(name);\r
+ }\r
+\r
+ public Builder description(String description) {\r
+ this.description = description;\r
+ return this;\r
+ }\r
+\r
+ public Builder reference(String reference) {\r
+ this.reference = reference;\r
+ return this;\r
+ }\r
+\r
+ public Builder lengthStatements(\r
+ final List<LengthConstraint> lengthStatements) {\r
+ this.lengthStatements = lengthStatements;\r
+ return this;\r
+ }\r
+\r
+ public Builder patterns(final List<PatternConstraint> patterns) {\r
+ this.patterns = patterns;\r
+ return this;\r
+ }\r
+\r
+ public Builder rangeStatements(\r
+ final List<RangeConstraint> rangeStatements) {\r
+ this.rangeStatements = rangeStatements;\r
+ return this;\r
+ }\r
+\r
+ public Builder extensions(final List<ExtensionDefinition> extensions) {\r
+ this.extensions = extensions;\r
+ return this;\r
+ }\r
+\r
+ public Builder lengthConstraint(final LengthConstraint lengthConstraint) {\r
+ this.lengthConstraint = lengthConstraint;\r
+ return this;\r
+ }\r
+\r
+ public Builder status(Status status) {\r
+ this.status = status;\r
+ return this;\r
+ }\r
+\r
+ public Builder units(String units) {\r
+ this.units = units;\r
+ return this;\r
+ }\r
+\r
+ public Builder defaultValue(final Object defaultValue) {\r
+ this.defaultValue = defaultValue;\r
+ return this;\r
+ }\r
+\r
+ public UnknownTypeDefinition build() {\r
+ return new UnknownType(this);\r
+ }\r
+ }\r
+\r
+ private UnknownType(Builder builder) {\r
+ this.name = builder.name;\r
+ this.path = builder.path;\r
+ this.description = builder.description;\r
+ this.reference = builder.reference;\r
+ this.lengthStatements = builder.lengthStatements;\r
+ this.patterns = builder.patterns;\r
+ this.rangeStatements = builder.rangeStatements;\r
+ this.extensions = builder.extensions;\r
+ this.lengthConstraint = builder.lengthConstraint;\r
+ this.status = builder.status;\r
+ this.units = builder.units;\r
+ this.defaultValue = builder.defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ */\r
+ @Override\r
+ public UnknownTypeDefinition getBaseType() {\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
+ */\r
+ @Override\r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue\r
+ * ()\r
+ */\r
+ @Override\r
+ public Object getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
+ */\r
+ @Override\r
+ public QName getQName() {\r
+ return name;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
+ */\r
+ @Override\r
+ public SchemaPath getPath() {\r
+ return path;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
+ */\r
+ @Override\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
+ */\r
+ @Override\r
+ public String getReference() {\r
+ return reference;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
+ */\r
+ @Override\r
+ public Status getStatus() {\r
+ return status;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes\r
+ * ()\r
+ */\r
+ @Override\r
+ public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+ return extensions;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.type.UnknownTypeDefinition\r
+ * #getRangeStatements()\r
+ */\r
+ @Override\r
+ public List<RangeConstraint> getRangeStatements() {\r
+ return rangeStatements;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.type.UnknownTypeDefinition\r
+ * #getLengthStatements()\r
+ */\r
+ @Override\r
+ public List<LengthConstraint> getLengthStatements() {\r
+ return lengthStatements;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.type.UnknownTypeDefinition\r
+ * #getPatterns()\r
+ */\r
+ @Override\r
+ public List<PatternConstraint> getPatterns() {\r
+ return patterns;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.type.UnknownTypeDefinition\r
+ * #getLengthConstraint()\r
+ */\r
+ @Override\r
+ public LengthConstraint getLengthConstraint() {\r
+ return lengthConstraint;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
+ result = prime * result\r
+ + ((description == null) ? 0 : description.hashCode());\r
+ result = prime * result\r
+ + ((extensions == null) ? 0 : extensions.hashCode());\r
+ result = prime\r
+ * result\r
+ + ((lengthConstraint == null) ? 0 : lengthConstraint.hashCode());\r
+ result = prime\r
+ * result\r
+ + ((lengthStatements == null) ? 0 : lengthStatements.hashCode());\r
+ result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ result = prime * result\r
+ + ((patterns == null) ? 0 : patterns.hashCode());\r
+ result = prime * result\r
+ + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());\r
+ result = prime * result\r
+ + ((reference == null) ? 0 : reference.hashCode());\r
+ result = prime * result + ((status == null) ? 0 : status.hashCode());\r
+ result = prime * result + ((units == null) ? 0 : units.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ UnknownType other = (UnknownType) obj;\r
+ if (defaultValue == null) {\r
+ if (other.defaultValue != null) {\r
+ return false;\r
+ }\r
+ } else if (!defaultValue.equals(other.defaultValue)) {\r
+ return false;\r
+ }\r
+ if (description == null) {\r
+ if (other.description != null) {\r
+ return false;\r
+ }\r
+ } else if (!description.equals(other.description)) {\r
+ return false;\r
+ }\r
+ if (extensions == null) {\r
+ if (other.extensions != null) {\r
+ return false;\r
+ }\r
+ } else if (!extensions.equals(other.extensions)) {\r
+ return false;\r
+ }\r
+ if (lengthConstraint == null) {\r
+ if (other.lengthConstraint != null) {\r
+ return false;\r
+ }\r
+ } else if (!lengthConstraint.equals(other.lengthConstraint)) {\r
+ return false;\r
+ }\r
+ if (lengthStatements == null) {\r
+ if (other.lengthStatements != null) {\r
+ return false;\r
+ }\r
+ } else if (!lengthStatements.equals(other.lengthStatements)) {\r
+ return false;\r
+ }\r
+ if (name == null) {\r
+ if (other.name != null) {\r
+ return false;\r
+ }\r
+ } else if (!name.equals(other.name)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ if (patterns == null) {\r
+ if (other.patterns != null) {\r
+ return false;\r
+ }\r
+ } else if (!patterns.equals(other.patterns)) {\r
+ return false;\r
+ }\r
+ if (rangeStatements == null) {\r
+ if (other.rangeStatements != null) {\r
+ return false;\r
+ }\r
+ } else if (!rangeStatements.equals(other.rangeStatements)) {\r
+ return false;\r
+ }\r
+ if (reference == null) {\r
+ if (other.reference != null) {\r
+ return false;\r
+ }\r
+ } else if (!reference.equals(other.reference)) {\r
+ return false;\r
+ }\r
+ if (status != other.status) {\r
+ return false;\r
+ }\r
+ if (units == null) {\r
+ if (other.units != null) {\r
+ return false;\r
+ }\r
+ } else if (!units.equals(other.units)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder builder2 = new StringBuilder();\r
+ builder2.append("UnknownType [name=");\r
+ builder2.append(name);\r
+ builder2.append(", path=");\r
+ builder2.append(path);\r
+ builder2.append(", description=");\r
+ builder2.append(description);\r
+ builder2.append(", reference=");\r
+ builder2.append(reference);\r
+ builder2.append(", lengthStatements=");\r
+ builder2.append(lengthStatements);\r
+ builder2.append(", patterns=");\r
+ builder2.append(patterns);\r
+ builder2.append(", rangeStatements=");\r
+ builder2.append(rangeStatements);\r
+ builder2.append(", extensions=");\r
+ builder2.append(extensions);\r
+ builder2.append(", lengthConstraint=");\r
+ builder2.append(lengthConstraint);\r
+ builder2.append(", status=");\r
+ builder2.append(status);\r
+ builder2.append(", units=");\r
+ builder2.append(units);\r
+ builder2.append(", defaultValue=");\r
+ builder2.append(defaultValue);\r
+ builder2.append("]");\r
+ return builder2.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.model.util;\r
+\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.opendaylight.controller.model.api.type.BinaryTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.BitsTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.BooleanTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.DecimalTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.model.api.type.StringTypeDefinition;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+\r
+public class YangTypesConverter {\r
+\r
+ private static final Map<String, TypeDefinition<? extends TypeDefinition<?>>> baseYangTypeMap = new HashMap<String, TypeDefinition<? extends TypeDefinition<?>>>();\r
+ private static final Set<String> baseYangTypes = new HashSet<String>();\r
+\r
+ private static final TypeDefinition<BinaryTypeDefinition> BINARY = new BinaryType();\r
+ private static final TypeDefinition<BitsTypeDefinition> BITS = new BitsType();\r
+ private static final TypeDefinition<BooleanTypeDefinition> BOOLEAN_TYPE = new BooleanType();\r
+ private static final TypeDefinition<IntegerTypeDefinition> INT8_TYPE = new Int8();\r
+ private static final TypeDefinition<IntegerTypeDefinition> INT16_TYPE = new Int16();\r
+ private static final TypeDefinition<IntegerTypeDefinition> INT32_TYPE = new Int32();\r
+ private static final TypeDefinition<IntegerTypeDefinition> INT64_TYPE = new Int64();\r
+ private static final TypeDefinition<StringTypeDefinition> STRING_TYPE = new StringType();\r
+ private static final TypeDefinition<IntegerTypeDefinition> UINT8_TYPE = new Uint8();\r
+ private static final TypeDefinition<IntegerTypeDefinition> UINT16_TYPE = new Int16();\r
+ private static final TypeDefinition<IntegerTypeDefinition> UINT32_TYPE = new Int32();\r
+ private static final TypeDefinition<IntegerTypeDefinition> UINT64_TYPE = new Int64();\r
+\r
+ static {\r
+ baseYangTypeMap.put("binary", BINARY);\r
+ baseYangTypeMap.put("bits", BITS);\r
+ baseYangTypeMap.put("boolean", BOOLEAN_TYPE);\r
+ baseYangTypeMap.put("int8", INT8_TYPE);\r
+ baseYangTypeMap.put("int16", INT16_TYPE);\r
+ baseYangTypeMap.put("int32", INT32_TYPE);\r
+ baseYangTypeMap.put("int64", INT64_TYPE);\r
+ baseYangTypeMap.put("string", STRING_TYPE);\r
+ baseYangTypeMap.put("uint8", UINT8_TYPE);\r
+ baseYangTypeMap.put("uint16", UINT16_TYPE);\r
+ baseYangTypeMap.put("uint32", UINT32_TYPE);\r
+ baseYangTypeMap.put("uint64", UINT64_TYPE);\r
+\r
+ baseYangTypes.add("binary");\r
+ baseYangTypes.add("bits");\r
+ baseYangTypes.add("boolean");\r
+ baseYangTypes.add("decimal64");\r
+ baseYangTypes.add("enumeration");\r
+ baseYangTypes.add("int8");\r
+ baseYangTypes.add("int16");\r
+ baseYangTypes.add("int32");\r
+ baseYangTypes.add("int64");\r
+ baseYangTypes.add("string");\r
+ baseYangTypes.add("uint8");\r
+ baseYangTypes.add("uint16");\r
+ baseYangTypes.add("uint32");\r
+ baseYangTypes.add("uint64");\r
+ }\r
+\r
+ public static boolean isBaseYangType(String type) {\r
+ return baseYangTypes.contains(type);\r
+ }\r
+\r
+ public static TypeDefinition<?> javaTypeForBaseYangType(QName typeQName) {\r
+ TypeDefinition<?> type = baseYangTypeMap.get(typeQName.getLocalName());\r
+ return type;\r
+ }\r
+\r
+ public static TypeDefinition<?> javaTypeForBaseYangType(String typeName) {\r
+ TypeDefinition<?> type = baseYangTypeMap.get(typeName);\r
+ return type;\r
+ }\r
+\r
+ public static TypeDefinition<IntegerTypeDefinition> javaTypeForBaseYangIntegerType(\r
+ String typeName, List<RangeConstraint> ranges) {\r
+ if (typeName.equals("int8")) {\r
+ return new Int8(ranges, null);\r
+ } else if (typeName.equals("int16")) {\r
+ return new Int16(ranges, null);\r
+ } else if (typeName.equals("int32")) {\r
+ return new Int32(ranges, null);\r
+ } else if (typeName.equals("int64")) {\r
+ return new Int64(ranges, null);\r
+ } else if (typeName.equals("uint8")) {\r
+ return new Uint8(ranges, null);\r
+ } else if (typeName.equals("uint16")) {\r
+ return new Uint16(ranges, null);\r
+ } else if (typeName.equals("uint32")) {\r
+ return new Uint32(ranges, null);\r
+ } else if (typeName.equals("uint64")) {\r
+ return new Uint64(ranges, null);\r
+ }\r
+ return null;\r
+ }\r
+\r
+ public static TypeDefinition<DecimalTypeDefinition> javaTypeForBaseYangDecimal64Type(\r
+ List<RangeConstraint> rangeStatements, int fractionDigits) {\r
+ return new Decimal64(rangeStatements, fractionDigits);\r
+ }\r
+\r
+}\r