Increased version of binding-generator to 0.5.5-SNAPSHOT.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-generator-util / src / main / java / org / opendaylight / controller / binding / generator / util / Types.java
index 26be94351c67b9db724d7fd27a44abfbf26c9051..ac2630063bf1b6ea8bd4f82bf0bb746a81d6fb2d 100644 (file)
-/*\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.binding.generator.util;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.ConcreteType;\r
-import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-import org.opendaylight.controller.yang.binding.Augmentable;\r
-import org.opendaylight.controller.yang.binding.Augmentation;\r
-import org.opendaylight.controller.yang.binding.DataObject;\r
-\r
-public final class Types {\r
-    private static final Type SET_TYPE = typeForClass(Set.class);\r
-    private static final Type LIST_TYPE = typeForClass(List.class);\r
-    private static final Type MAP_TYPE = typeForClass(Map.class);\r
-    public static final Type DATA_OBJECT = typeForClass(DataObject.class);\r
-\r
-    public static ConcreteType voidType() {\r
-        return new ConcreteTypeImpl(Void.class.getPackage().getName(),\r
-                Void.class.getSimpleName());\r
-    }\r
-\r
-    public static final Type primitiveType(final String primitiveType) {\r
-        return new ConcreteTypeImpl("", primitiveType);\r
-    }\r
-\r
-\r
-    /**\r
-     * Returns an instance of {@link ConcreteType} describing the class\r
-     * \r
-     * @param cls\r
-     *            Class to describe\r
-     * @return Description of class\r
-     */\r
-    public static ConcreteType typeForClass(Class<?> cls) {\r
-        return new ConcreteTypeImpl(cls.getPackage().getName(),\r
-                cls.getSimpleName());\r
-    }\r
-\r
-    /**\r
-     * Returns an instance of {@link ParameterizedType} describing the typed\r
-     * {@link Map}<K,V>\r
-     * \r
-     * @param keyType\r
-     *            Key Type\r
-     * @param valueType\r
-     *            Value Type\r
-     * @return Description of generic type instance\r
-     */\r
-    public static ParameterizedType mapTypeFor(Type keyType, Type valueType) {\r
-        return parameterizedTypeFor(MAP_TYPE, keyType, valueType);\r
-    }\r
-\r
-    /**\r
-     * Returns an instance of {@link ParameterizedType} describing the typed\r
-     * {@link Set}<V> with concrete type of value.\r
-     * \r
-     * @param valueType\r
-     *            Value Type\r
-     * @return Description of generic type instance of Set\r
-     */\r
-    public static ParameterizedType setTypeFor(Type valueType) {\r
-        return parameterizedTypeFor(SET_TYPE, valueType);\r
-    }\r
-\r
-    /**\r
-     * Returns an instance of {@link ParameterizedType} describing the typed\r
-     * {@link List}<V> with concrete type of value.\r
-     * \r
-     * @param valueType\r
-     *            Value Type\r
-     * @return Description of type instance of List\r
-     */\r
-    public static ParameterizedType listTypeFor(Type valueType) {\r
-        return parameterizedTypeFor(LIST_TYPE, valueType);\r
-    }\r
-\r
-    /**\r
-     * \r
-     * @param type\r
-     * @param parameters\r
-     * @return\r
-     */\r
-    public static ParameterizedType parameterizedTypeFor(Type type,\r
-            Type... parameters) {\r
-        return new ParametrizedTypeImpl(type, parameters);\r
-    }\r
-    \r
-    public static ParameterizedType augmentableTypeFor(Type valueType) {\r
-        final Type augmentable = typeForClass(Augmentable.class);\r
-        return parameterizedTypeFor(augmentable, valueType);\r
-    }\r
-    \r
-    public static ParameterizedType augmentationTypeFor(Type valueType) {\r
-        final Type augmentation = typeForClass(Augmentation.class);\r
-        return parameterizedTypeFor(augmentation, valueType);\r
-    }\r
-    \r
-    private static class ConcreteTypeImpl extends AbstractBaseType implements\r
-            ConcreteType {\r
-        private ConcreteTypeImpl(String pkName, String name) {\r
-            super(pkName, name);\r
-        }\r
-    }\r
-\r
-    private static class ParametrizedTypeImpl extends AbstractBaseType\r
-            implements ParameterizedType {\r
-        private Type[] actualTypes;\r
-        private Type rawType;\r
-\r
-        @Override\r
-        public Type[] getActualTypeArguments() {\r
-\r
-            return actualTypes;\r
-        }\r
-\r
-        @Override\r
-        public Type getRawType() {\r
-            return rawType;\r
-        }\r
-\r
-        public ParametrizedTypeImpl(Type rawType, Type[] actTypes) {\r
-            super(rawType.getPackageName(), rawType.getName());\r
-            this.rawType = rawType;\r
-            this.actualTypes = actTypes;\r
-        }\r
-\r
-    }\r
-}\r
+/*
+ * 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.binding.generator.util;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
+import org.opendaylight.controller.sal.binding.model.api.ConcreteType;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.binding.model.api.WildcardType;
+import org.opendaylight.yangtools.yang.binding.Augmentable;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public final class Types {
+    private static final Type SET_TYPE = typeForClass(Set.class);
+    private static final Type LIST_TYPE = typeForClass(List.class);
+    private static final Type MAP_TYPE = typeForClass(Map.class);
+    public static final Type DATA_OBJECT = typeForClass(DataObject.class);
+
+    public static ConcreteType voidType() {
+        return new ConcreteTypeImpl(Void.class.getPackage().getName(), Void.class.getSimpleName());
+    }
+
+    public static final Type primitiveType(final String primitiveType) {
+        return new ConcreteTypeImpl("", primitiveType);
+    }
+
+    /**
+     * Returns an instance of {@link ConcreteType} describing the class
+     *
+     * @param cls
+     *            Class to describe
+     * @return Description of class
+     */
+    public static ConcreteType typeForClass(Class<?> cls) {
+        return new ConcreteTypeImpl(cls.getPackage().getName(), cls.getSimpleName());
+    }
+
+    /**
+     * Returns an instance of {@link ParameterizedType} describing the typed
+     * {@link Map}<K,V>
+     *
+     * @param keyType
+     *            Key Type
+     * @param valueType
+     *            Value Type
+     * @return Description of generic type instance
+     */
+    public static ParameterizedType mapTypeFor(Type keyType, Type valueType) {
+        return parameterizedTypeFor(MAP_TYPE, keyType, valueType);
+    }
+
+    /**
+     * Returns an instance of {@link ParameterizedType} describing the typed
+     * {@link Set}<V> with concrete type of value.
+     *
+     * @param valueType
+     *            Value Type
+     * @return Description of generic type instance of Set
+     */
+    public static ParameterizedType setTypeFor(Type valueType) {
+        return parameterizedTypeFor(SET_TYPE, valueType);
+    }
+
+    /**
+     * Returns an instance of {@link ParameterizedType} describing the typed
+     * {@link List}<V> with concrete type of value.
+     *
+     * @param valueType
+     *            Value Type
+     * @return Description of type instance of List
+     */
+    public static ParameterizedType listTypeFor(Type valueType) {
+        return parameterizedTypeFor(LIST_TYPE, valueType);
+    }
+
+    public static GeneratedTransferObject getBaseIdentityTO() {
+        Class<BaseIdentity> cls = BaseIdentity.class;
+        GeneratedTOBuilderImpl gto = new GeneratedTOBuilderImpl(cls.getPackage().getName(), cls.getSimpleName());
+        return gto.toInstance();
+    }
+
+    /**
+     *
+     * @param type
+     * @param parameters
+     * @return
+     */
+    public static ParameterizedType parameterizedTypeFor(Type type, Type... parameters) {
+        return new ParametrizedTypeImpl(type, parameters);
+    }
+
+    public static WildcardType wildcardTypeFor(String packageName, String typeName) {
+        return new WildcardTypeImpl(packageName, typeName);
+    }
+
+    public static ParameterizedType augmentableTypeFor(Type valueType) {
+        final Type augmentable = typeForClass(Augmentable.class);
+        return parameterizedTypeFor(augmentable, valueType);
+    }
+
+    public static ParameterizedType augmentationTypeFor(Type valueType) {
+        final Type augmentation = typeForClass(Augmentation.class);
+        return parameterizedTypeFor(augmentation, valueType);
+    }
+
+    private static class ConcreteTypeImpl extends AbstractBaseType implements ConcreteType {
+        private ConcreteTypeImpl(String pkName, String name) {
+            super(pkName, name);
+        }
+    }
+
+    private static class ParametrizedTypeImpl extends AbstractBaseType implements ParameterizedType {
+        private Type[] actualTypes;
+        private Type rawType;
+
+        @Override
+        public Type[] getActualTypeArguments() {
+
+            return actualTypes;
+        }
+
+        @Override
+        public Type getRawType() {
+            return rawType;
+        }
+
+        public ParametrizedTypeImpl(Type rawType, Type[] actTypes) {
+            super(rawType.getPackageName(), rawType.getName());
+            this.rawType = rawType;
+            this.actualTypes = actTypes;
+        }
+
+    }
+
+    private static class WildcardTypeImpl extends AbstractBaseType implements WildcardType {
+        public WildcardTypeImpl(String packageName, String typeName) {
+            super(packageName, typeName);
+        }
+    }
+
+}