BUG-8043: introduce RangeRestrictedTypeDefinition
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / type / CompatUtils.java
index 08bff3b637c70ae0011b2ff0fe62afaf81ed3e8c..83af46d85f9e229465c71b57d8c5bbc7670efc28 100644 (file)
@@ -20,11 +20,10 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
-import org.opendaylight.yangtools.yang.model.util.ExtendedType;
 
 /**
- * Compatibility utilities for dealing with differences between the {@link ExtendedType}-driven type representation
- * versus the representation this package models.
+ * Compatibility utilities for dealing with differences between the old parser's ExtendedType-driven type
+ * representation versus the representation this package models.
  *
  * @deprecated This class is provided strictly for compatibility only. No new users should be introduced, as this class
  *             is scheduled for removal when its two OpenDaylight users, Java Binding v1 and YANG JMX Bindings are
@@ -42,6 +41,7 @@ public final class CompatUtils {
      * declaration has not restricted the type further -- which is not something available via
      * {@link TypeDefinition#getBaseType()}.
      *
+     * <p>
      * Here are the possible scenarios:
      *
      * <pre>
@@ -81,6 +81,7 @@ public final class CompatUtils {
      * </pre>
      * The leaf type's schema path will not match the schema path of the leaf. We do NOT want to strip it.
      *
+     * <p>
      * The situation is different for types which do not have a default instantiation in YANG: leafref, enumeration,
      * identityref, decimal64, bits and union. If these types are defined within this leaf's statement, a base type
      * will be instantiated. If the leaf defines a default statement, this base type will be visible via getBaseType().
@@ -112,11 +113,6 @@ public final class CompatUtils {
         final TypeDefinition<?> leafType = leaf.getType();
         Preconditions.checkNotNull(leafType);
 
-        if (leafType instanceof ExtendedType) {
-            // Old parser referring to a typedef
-            return leafType;
-        }
-
         if (!leaf.getPath().equals(leafType.getPath())) {
             // Old parser semantics, or no new default/units defined for this leaf
             return leafType;
@@ -176,8 +172,8 @@ public final class CompatUtils {
         final List<PatternConstraint> patterns = type.getPatternConstraints();
         final List<LengthConstraint> lengths = type.getLengthConstraints();
 
-        if ((patterns.isEmpty() || patterns.equals(base.getPatternConstraints())) &&
-                (lengths.isEmpty() || lengths.equals(base.getLengthConstraints()))) {
+        if ((patterns.isEmpty() || patterns.equals(base.getPatternConstraints()))
+                && (lengths.isEmpty() || lengths.equals(base.getLengthConstraints()))) {
             return base;
         }