Remove BaseYangTypesProvider
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / yang / types / AbstractTypeProvider.java
index 73fa9bf7bb0dd8e79f662393542c796b6be11b69..7678e3a2941f3900fe4f0790b303804d6ed858ac 100644 (file)
@@ -126,24 +126,7 @@ abstract class AbstractTypeProvider implements TypeProvider {
 
     @Override
     public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> typeDefinition, final SchemaNode parentNode,
-            final boolean lenientRelativeLeafrefs) {
-        return javaTypeForSchemaDefinitionType(typeDefinition, parentNode, null, lenientRelativeLeafrefs);
-    }
-
-    /**
-     * Converts schema definition type <code>typeDefinition</code> to JAVA <code>Type</code>.
-     *
-     * @param typeDefinition type definition which is converted to JAVA type
-     * @throws IllegalArgumentException
-     *             <ul>
-     *             <li>if <code>typeDefinition</code> equal null</li>
-     *             <li>if Qname of <code>typeDefinition</code> equal null</li>
-     *             <li>if name of <code>typeDefinition</code> equal null</li>
-     *             </ul>
-     */
-    @Override
-    public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> typeDefinition, final SchemaNode parentNode,
-            final Restrictions restrictions, final boolean lenientRelativeLeafrefs) {
+            final Restrictions restrictions) {
         throw new UnsupportedOperationException();
     }
 
@@ -645,7 +628,7 @@ abstract class AbstractTypeProvider implements TypeProvider {
 
         final TypeDefinition<?> baseType = baseTypeDefForExtendedType(unionSubtype);
         if (unionTypeName.equals(baseType.getQName().getLocalName())) {
-            final Type javaType = BaseYangTypesProvider.INSTANCE.javaTypeForSchemaDefinitionType(baseType, parentNode,
+            final Type javaType = baseJavaTypeForSchema(baseType, parentNode,
                 BindingGeneratorUtil.getRestrictions(unionSubtype));
             if (javaType != null) {
                 updateUnionTypeAsProperty(parentUnionGenTOBuilder, javaType, unionTypeName);
@@ -670,6 +653,13 @@ abstract class AbstractTypeProvider implements TypeProvider {
         }
     }
 
+    private static Type baseJavaTypeForSchema(final TypeDefinition<?> type, final SchemaNode parentNode,
+            final Restrictions restrictions) {
+        final String typeName = type.getQName().getLocalName();
+        final Type mapped = BaseYangTypes.javaTypeForYangType(typeName);
+        return mapped == null || restrictions == null ? mapped : Types.restrictedType(mapped, restrictions);
+    }
+
     /**
      * Searches for generated TO for <code>searchedTypeDef</code> type  definition
      * in {@link #genTypeDefsContextMap genTypeDefsContextMap}.