Share Class Type 56/73156/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 18 Jun 2018 20:05:34 +0000 (22:05 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 18 Jun 2018 20:05:34 +0000 (22:05 +0200)
Add a constant and for java.lang.Class ConcreteType and an accessor
for its parameterizations.

Change-Id: I80ee9a3da1ac13d7066f5ff1e2f546684d6423fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/AbstractTypeProvider.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/model/util/Types.java

index 2854f65639a025508a304e8bc5184c513498ddf3..9b33d29235d33d670d84c42c09e68aea0221bd39 100644 (file)
@@ -394,8 +394,7 @@ public abstract class AbstractTypeProvider implements TypeProvider {
         final String basePackageName = BindingMapping.getRootPackageName(module.getQNameModule());
         final JavaTypeName identifier = JavaTypeName.create(BindingGeneratorUtil.packageNameForGeneratedType(basePackageName,
             identity.getPath()), BindingMapping.getClassName(identity.getQName()));
-        final Type paramType = Types.wildcardTypeFor(identifier);
-        return Types.parameterizedTypeFor(Types.typeForClass(Class.class), paramType);
+        return Types.classType(Types.wildcardTypeFor(identifier));
     }
 
     /**
index 697a8952121e83cd91eb62bd370432f76b959dd7..1f0226b82cc2d97feeda0efa1fc378dfbbbfa715 100644 (file)
@@ -57,6 +57,7 @@ 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);
@@ -67,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.
      *