Merge "Created Yang to Java Builder pattern class generator"
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-generator-util / src / main / java / org / opendaylight / controller / binding / generator / util / Types.java
index 2966246601ed3c8c0fe2ede8b1720a3dde8aed50..2e5bbf0a07a6f0a73d41af7f92c510880aae6963 100644 (file)
@@ -11,31 +11,36 @@ import java.util.List;
 import java.util.Map;\r
 import java.util.Set;\r
 \r
+import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;\r
 import org.opendaylight.controller.sal.binding.model.api.ConcreteType;\r
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;\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.sal.binding.model.api.WildcardType;\r
 import org.opendaylight.controller.yang.binding.Augmentable;\r
 import org.opendaylight.controller.yang.binding.Augmentation;\r
+import org.opendaylight.controller.yang.binding.BaseIdentity;\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
-    \r
     public static final Type DATA_OBJECT = typeForClass(DataObject.class);\r
-    \r
-    private Types() {\r
-    }\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
+     *\r
      * @param cls\r
      *            Class to describe\r
      * @return Description of class\r
@@ -48,7 +53,7 @@ public final class Types {
     /**\r
      * Returns an instance of {@link ParameterizedType} describing the typed\r
      * {@link Map}<K,V>\r
-     * \r
+     *\r
      * @param keyType\r
      *            Key Type\r
      * @param valueType\r
@@ -62,7 +67,7 @@ public final class Types {
     /**\r
      * Returns an instance of {@link ParameterizedType} describing the typed\r
      * {@link Set}<V> with concrete type of value.\r
-     * \r
+     *\r
      * @param valueType\r
      *            Value Type\r
      * @return Description of generic type instance of Set\r
@@ -74,7 +79,7 @@ public final class Types {
     /**\r
      * Returns an instance of {@link ParameterizedType} describing the typed\r
      * {@link List}<V> with concrete type of value.\r
-     * \r
+     *\r
      * @param valueType\r
      *            Value Type\r
      * @return Description of type instance of List\r
@@ -83,8 +88,15 @@ public final class Types {
         return parameterizedTypeFor(LIST_TYPE, valueType);\r
     }\r
 \r
+    public static GeneratedTransferObject getBaseIdentityTO() {\r
+        Class<BaseIdentity> cls = BaseIdentity.class;\r
+        GeneratedTOBuilderImpl gto = new GeneratedTOBuilderImpl(cls.getPackage().getName(),\r
+                cls.getSimpleName());\r
+        return gto.toInstance();\r
+    }\r
+\r
     /**\r
-     * \r
+     *\r
      * @param type\r
      * @param parameters\r
      * @return\r
@@ -93,17 +105,21 @@ public final class Types {
             Type... parameters) {\r
         return new ParametrizedTypeImpl(type, parameters);\r
     }\r
-    \r
+\r
+    public static WildcardType wildcardTypeFor(String packageName, String typeName) {\r
+        return new WildcardTypeImpl(packageName, typeName);\r
+    }\r
+\r
     public static ParameterizedType augmentableTypeFor(Type valueType) {\r
         final Type augmentable = typeForClass(Augmentable.class);\r
         return parameterizedTypeFor(augmentable, valueType);\r
     }\r
-    \r
+\r
     public static ParameterizedType augmentationTypeFor(Type valueType) {\r
         final Type augmentation = typeForClass(Augmentation.class);\r
         return parameterizedTypeFor(augmentation, valueType);\r
     }\r
-    \r
+\r
     private static class ConcreteTypeImpl extends AbstractBaseType implements\r
             ConcreteType {\r
         private ConcreteTypeImpl(String pkName, String name) {\r
@@ -134,4 +150,12 @@ public final class Types {
         }\r
 \r
     }\r
+\r
+    private static class WildcardTypeImpl extends AbstractBaseType\r
+            implements WildcardType {\r
+        public WildcardTypeImpl(String packageName, String typeName) {\r
+            super(packageName, typeName);\r
+        }\r
+    }\r
+\r
 }\r