Update the API generation code and code generation sample
[controller.git] / opendaylight / sal / yang-prototype / code-generator / yang-model-parser-impl / src / main / java / org / opendaylight / controller / yang / model / parser / builder / impl / UsesNodeBuilderImpl.java
index 2096c3bdf83f671088a01fa91a571fb324ba1950..9490e7f0a4aa4091fa57d75d1a84d0f06c4e8864 100644 (file)
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.yang.model.parser.builder.impl;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;
-import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.UsesNode;
-import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
-import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
-
-public class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
-
-    private final UsesNodeImpl instance;
-    private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();
-
-    UsesNodeBuilderImpl(String groupingPathStr) {
-        SchemaPath groupingPath = parseUsesPath(groupingPathStr);
-        instance = new UsesNodeImpl(groupingPath);
-    }
-
-    @Override
-    public UsesNode build() {
-        // AUGMENTATIONS
-        final Set<AugmentationSchema> augments = new HashSet<AugmentationSchema>();
-        for (AugmentationSchemaBuilder builder : addedAugments) {
-            augments.add(builder.build());
-        }
-        instance.setAugmentations(augments);
-
-        return instance;
-    }
-
-    @Override
-    public void addAugment(AugmentationSchemaBuilder augmentBuilder) {
-        addedAugments.add(augmentBuilder);
-    }
-
-    @Override
-    public void setAugmenting(boolean augmenting) {
-        instance.setAugmenting(augmenting);
-    }
-
-    private SchemaPath parseUsesPath(String augmentPath) {
-        String[] splittedPath = augmentPath.split("/");
-        List<QName> path = new ArrayList<QName>();
-        QName name;
-        for (String pathElement : splittedPath) {
-            String[] splittedElement = pathElement.split(":");
-            if (splittedElement.length == 1) {
-                name = new QName(null, null, null, splittedElement[0]);
-            } else {
-                name = new QName(null, null, splittedElement[0],
-                        splittedElement[1]);
-            }
-            path.add(name);
-        }
-        final boolean absolute = augmentPath.startsWith("/");
-        return new SchemaPath(path, absolute);
-    }
-
-    private static class UsesNodeImpl implements UsesNode {
-
-        private final SchemaPath groupingPath;
-        private Set<AugmentationSchema> augmentations = Collections.emptySet();
-        private boolean augmenting;
-
-        private UsesNodeImpl(SchemaPath groupingPath) {
-            this.groupingPath = groupingPath;
-        }
-
-        @Override
-        public SchemaPath getGroupingPath() {
-            return groupingPath;
-        }
-
-        @Override
-        public Set<AugmentationSchema> getAugmentations() {
-            return augmentations;
-        }
-
-        private void setAugmentations(Set<AugmentationSchema> augmentations) {
-            if (augmentations != null) {
-                this.augmentations = augmentations;
-            }
-        }
-
-        @Override
-        public boolean isAugmenting() {
-            return augmenting;
-        }
-
-        private void setAugmenting(boolean augmenting) {
-            this.augmenting = augmenting;
-        }
-
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((groupingPath == null) ? 0 : groupingPath.hashCode());
-            result = prime * result + ((augmentations == null) ? 0 : augmentations.hashCode());
-            result = prime * result + (augmenting ? 1231 : 1237);
-            return result;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            UsesNodeImpl other = (UsesNodeImpl) obj;
-            if (groupingPath == null) {
-                if (other.groupingPath != null) {
-                    return false;
-                }
-            } else if (!groupingPath.equals(other.groupingPath)) {
-                return false;
-            }
-            if (augmentations == null) {
-                if (other.augmentations != null) {
-                    return false;
-                }
-            } else if (!augmentations.equals(other.augmentations)) {
-                return false;
-            }
-            if (augmenting != other.augmenting) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder sb = new StringBuilder(
-                    UsesNodeImpl.class.getSimpleName());
-            sb.append("[groupingPath=" + groupingPath +"]");
-            return sb.toString();
-        }
-
-    }
-
-}
+/*\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.parser.builder.impl;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\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.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
+import org.opendaylight.controller.yang.model.api.SchemaNode;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
+import org.opendaylight.controller.yang.model.api.UsesNode;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.Builder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;\r
+\r
+public class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {\r
+\r
+    private final UsesNodeImpl instance;\r
+    private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();\r
+\r
+    UsesNodeBuilderImpl(String groupingPathStr) {\r
+        SchemaPath groupingPath = parseUsesPath(groupingPathStr);\r
+        instance = new UsesNodeImpl(groupingPath);\r
+    }\r
+\r
+    @Override\r
+    public UsesNode build() {\r
+        // AUGMENTATIONS\r
+        final Set<AugmentationSchema> augments = new HashSet<AugmentationSchema>();\r
+        for (AugmentationSchemaBuilder builder : addedAugments) {\r
+            augments.add(builder.build());\r
+        }\r
+        instance.setAugmentations(augments);\r
+\r
+        return instance;\r
+    }\r
+\r
+    @Override\r
+    public void addAugment(AugmentationSchemaBuilder augmentBuilder) {\r
+        addedAugments.add(augmentBuilder);\r
+    }\r
+\r
+    @Override\r
+    public void setAugmenting(boolean augmenting) {\r
+        instance.setAugmenting(augmenting);\r
+    }\r
+\r
+    private SchemaPath parseUsesPath(String augmentPath) {\r
+        String[] splittedPath = augmentPath.split("/");\r
+        List<QName> path = new ArrayList<QName>();\r
+        QName name;\r
+        for (String pathElement : splittedPath) {\r
+            String[] splittedElement = pathElement.split(":");\r
+            if (splittedElement.length == 1) {\r
+                name = new QName(null, null, null, splittedElement[0]);\r
+            } else {\r
+                name = new QName(null, null, splittedElement[0],\r
+                        splittedElement[1]);\r
+            }\r
+            path.add(name);\r
+        }\r
+        final boolean absolute = augmentPath.startsWith("/");\r
+        return new SchemaPath(path, absolute);\r
+    }\r
+\r
+    private static class UsesNodeImpl implements UsesNode {\r
+\r
+        private final SchemaPath groupingPath;\r
+        private Set<AugmentationSchema> augmentations = Collections.emptySet();\r
+        private boolean augmenting;\r
+\r
+        private UsesNodeImpl(SchemaPath groupingPath) {\r
+            this.groupingPath = groupingPath;\r
+        }\r
+\r
+        @Override\r
+        public SchemaPath getGroupingPath() {\r
+            return groupingPath;\r
+        }\r
+\r
+        @Override\r
+        public Set<AugmentationSchema> getAugmentations() {\r
+            return augmentations;\r
+        }\r
+\r
+        private void setAugmentations(Set<AugmentationSchema> augmentations) {\r
+            if (augmentations != null) {\r
+                this.augmentations = augmentations;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public boolean isAugmenting() {\r
+            return augmenting;\r
+        }\r
+        \r
+        private void setAugmenting(boolean augmenting) {\r
+            this.augmenting = augmenting;\r
+        }\r
+        \r
+\r
+        @Override\r
+        public Map<SchemaPath, SchemaNode> getRefines() {\r
+            // TODO Auto-generated method stub\r
+            return null;\r
+        }\r
+        \r
+        @Override\r
+        public int hashCode() {\r
+            final int prime = 31;\r
+            int result = 1;\r
+            result = prime * result + ((groupingPath == null) ? 0 : groupingPath.hashCode());\r
+            result = prime * result + ((augmentations == null) ? 0 : augmentations.hashCode());\r
+            result = prime * result + (augmenting ? 1231 : 1237);\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
+            UsesNodeImpl other = (UsesNodeImpl) obj;\r
+            if (groupingPath == null) {\r
+                if (other.groupingPath != null) {\r
+                    return false;\r
+                }\r
+            } else if (!groupingPath.equals(other.groupingPath)) {\r
+                return false;\r
+            }\r
+            if (augmentations == null) {\r
+                if (other.augmentations != null) {\r
+                    return false;\r
+                }\r
+            } else if (!augmentations.equals(other.augmentations)) {\r
+                return false;\r
+            }\r
+            if (augmenting != other.augmenting) {\r
+                return false;\r
+            }\r
+            return true;\r
+        }\r
+\r
+        @Override\r
+        public String toString() {\r
+            StringBuilder sb = new StringBuilder(\r
+                    UsesNodeImpl.class.getSimpleName());\r
+            sb.append("[groupingPath=" + groupingPath +"]");\r
+            return sb.toString();\r
+        }\r
+    }\r
+}\r