Share Class Type
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / util / Types.java
index 03a70f05be5255ed8796dbeea3f97ad54414cac5..1f0226b82cc2d97feeda0efa1fc378dfbbbfa715 100644 (file)
@@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableRangeSet;
 import com.google.common.collect.Range;
 import com.google.common.collect.RangeSet;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.io.Serializable;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -56,7 +57,10 @@ public final class Types {
     public static final ConcreteType BYTE_ARRAY = typeForClass(byte[].class);
     public static final ConcreteType CHAR_ARRAY = typeForClass(char[].class);
 
+    private static final ConcreteType CLASS = typeForClass(Class.class);
+    private static final ConcreteType OBJECT = typeForClass(Object.class);
     private static final ConcreteType PRIMITIVE_VOID = typeForClass(void.class);
+    private static final ConcreteType SERIALIZABLE = typeForClass(Serializable.class);
 
     /**
      * It is not desirable to create instance of this class
@@ -64,6 +68,18 @@ public final class Types {
     private Types() {
     }
 
+    /**
+     * Returns an instance of {@link ParameterizedType} which represents JAVA <code>java.lang.Class</code> type
+     * specialized to specified type.
+     *
+     * @param type Type for which to specialize
+     * @return A parameterized type corresponding to {@code Class<Type>}
+     * @throws NullPointerException if {@code type} is null
+     */
+    public static ParameterizedType classType(final Type type) {
+        return parameterizedTypeFor(CLASS, type);
+    }
+
     /**
      * Returns an instance of {@link ConcreteType} which represents JAVA <code>java.lang.Void</code> type.
      *
@@ -73,6 +89,15 @@ public final class Types {
         return VOID;
     }
 
+    /**
+     * Returns an instance of {@link ConcreteType} which represents {@link Object} type.
+     *
+     * @return <code>ConcreteType</code> instance which represents {@link Object}
+     */
+    public static ConcreteType objectType() {
+        return OBJECT;
+    }
+
     /**
      * Returns an instance of {@link ConcreteType} which represents JAVA <code>void</code> type.
      *
@@ -82,6 +107,15 @@ public final class Types {
         return PRIMITIVE_VOID;
     }
 
+    /**
+     * Returns an instance of {@link ConcreteType} which represents {@link Serializable} type.
+     *
+     * @return <code>ConcreteType</code> instance which represents JAVA <code>{@link Serializable}</code>
+     */
+    public static ConcreteType serializableType() {
+        return SERIALIZABLE;
+    }
+
     /**
      * Returns an instance of {@link ConcreteType} describing the class
      *
@@ -154,6 +188,7 @@ public final class Types {
      *            JAVA <code>Type</code>s for actual parameter types
      * @return <code>ParametrizedType</code> reprezentation of <code>type</code>
      *         and its parameters <code>parameters</code>
+     * @throws NullPointerException if any argument is null
      */
     public static ParameterizedType parameterizedTypeFor(final Type type, final Type... parameters) {
         return new ParametrizedTypeImpl(type, parameters);