Binding generator v2 - uses statement - uses inner type #1
[mdsal.git] / binding2 / mdsal-binding2-generator-util / src / main / java / org / opendaylight / mdsal / binding / javav2 / generator / util / Types.java
index 3d3a8f4bd049ee8ed01cd4994437592748af54bb..a25bd4e12022f0e1d3a40231dd9000a4aad7867a 100644 (file)
@@ -123,6 +123,20 @@ public final class Types {
         }
     }
 
+    public static ConcreteType typeForClass(final Class<?> cls, final Restrictions restrictions,
+            final ModuleContext moduleContext) {
+        if (restrictions != null) {
+            if (restrictions instanceof DefaultRestrictions) {
+                return new ConcreteTypeImpl(cls.getPackage().getName(), cls.getSimpleName(), restrictions);
+            } else {
+                return new BaseTypeWithRestrictionsImpl(cls.getPackage().getName(), cls.getSimpleName(), restrictions,
+                        moduleContext);
+            }
+        } else {
+            return typeForClass(cls);
+        }
+    }
+
     /**
      * Returns an instance of {@link ParameterizedType} describing the typed
      * {@link Map}&lt;K,V&gt;
@@ -322,6 +336,12 @@ public final class Types {
             this.restrictions = Preconditions.checkNotNull(restrictions);
         }
 
+        private BaseTypeWithRestrictionsImpl(final String pkName, final String name, final Restrictions restrictions,
+                final ModuleContext moduleContext) {
+            super(pkName, name, moduleContext);
+            this.restrictions = Preconditions.checkNotNull(restrictions);
+        }
+
         @Override
         public Restrictions getRestrictions() {
             return this.restrictions;