Integrate JavaTypeName as Identifier
[mdsal.git] / binding / mdsal-binding-generator-impl / src / main / java / org / opendaylight / mdsal / binding / generator / util / BindingRuntimeContext.java
index 3a3f2d92abadd706b66ce514283fa205861dd8f9..15fba00be2826aa6b675095462c13c1dc3f20039 100644 (file)
@@ -35,6 +35,7 @@ import org.opendaylight.mdsal.binding.model.api.GeneratedType;
 import org.opendaylight.mdsal.binding.model.api.MethodSignature;
 import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
 import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
 import org.opendaylight.mdsal.binding.model.util.ReferencedTypeImpl;
 import org.opendaylight.yangtools.concepts.Immutable;
@@ -245,12 +246,7 @@ public class BindingRuntimeContext implements Immutable {
     }
 
     private static Type referencedType(final Class<?> type) {
-        return new ReferencedTypeImpl(type.getPackage().getName(), type.getSimpleName());
-    }
-
-    static Type referencedType(final String type) {
-        final int packageClassSeparator = type.lastIndexOf(DOT);
-        return new ReferencedTypeImpl(type.substring(0, packageClassSeparator), type.substring(packageClassSeparator + 1));
+        return new ReferencedTypeImpl(JavaTypeName.create(type));
     }
 
     /**
@@ -268,10 +264,6 @@ public class BindingRuntimeContext implements Immutable {
         return getTypeWithSchema(referencedType(type));
     }
 
-    public Entry<GeneratedType, WithStatus> getTypeWithSchema(final String type) {
-        return getTypeWithSchema(referencedType(type));
-    }
-
     private Entry<GeneratedType, WithStatus> getTypeWithSchema(final Type referencedType) {
         final WithStatus schema = runtimeTypes.findSchema(referencedType).orElseThrow(
             () -> new NullPointerException("Failed to find schema for type " + referencedType));
@@ -320,14 +312,6 @@ public class BindingRuntimeContext implements Immutable {
         return getEnumMapping(typeWithSchema);
     }
 
-    /**
-     * See {@link #getEnumMapping(Class)}}
-     */
-    public BiMap<String, String> getEnumMapping(final String enumClass) {
-        final Entry<GeneratedType, WithStatus> typeWithSchema = getTypeWithSchema(enumClass);
-        return getEnumMapping(typeWithSchema);
-    }
-
     private static BiMap<String, String> getEnumMapping(final Entry<GeneratedType, WithStatus> typeWithSchema) {
         final TypeDefinition<?> typeDef = (TypeDefinition<?>) typeWithSchema.getValue();
 
@@ -406,7 +390,7 @@ public class BindingRuntimeContext implements Immutable {
         if (type instanceof ReferencedTypeImpl) {
             return type;
         }
-        return new ReferencedTypeImpl(type.getPackageName(), type.getName());
+        return new ReferencedTypeImpl(type.getIdentifier());
     }
 
     private static Set<Type> collectAllContainerTypes(final GeneratedType type, final Set<Type> collection) {