Deprecate Types.augmentableTypeFor()
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / util / Types.java
index e3e199e7ae072552aadf28af3876547669273e82..99137a927204290eb05c72a028100da4a0892792 100644 (file)
@@ -34,7 +34,6 @@ import org.opendaylight.mdsal.binding.model.api.Restrictions;
 import org.opendaylight.mdsal.binding.model.api.Type;
 import org.opendaylight.mdsal.binding.model.api.WildcardType;
 import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.yang.binding.Augmentable;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
@@ -65,6 +64,8 @@ public final class Types {
     private static final @NonNull ConcreteType SERIALIZABLE = typeForClass(Serializable.class);
     private static final @NonNull ConcreteType SET_TYPE = typeForClass(Set.class);
 
+    private static final @NonNull ConcreteType AUGMENTATION = typeForClass(Augmentation.class);
+
     /**
      * It is not desirable to create instance of this class.
      */
@@ -153,6 +154,14 @@ public final class Types {
         return parameterizedTypeFor(MAP_TYPE, keyType, valueType);
     }
 
+    public static boolean isMapType(final ParameterizedType type) {
+        return MAP_TYPE.equals(type.getRawType());
+    }
+
+    public static boolean isMapType(final Type type) {
+        return type instanceof ParameterizedType && isMapType((ParameterizedType) type);
+    }
+
     /**
      * Returns an instance of {@link ParameterizedType} describing the typed {@link Set}<V> with concrete type
      * of value.
@@ -175,8 +184,12 @@ public final class Types {
         return parameterizedTypeFor(LIST_TYPE, valueType);
     }
 
+    public static boolean isListType(final ParameterizedType type) {
+        return LIST_TYPE.equals(type.getRawType());
+    }
+
     public static boolean isListType(final Type type) {
-        return type instanceof ParameterizedType && LIST_TYPE.equals(((ParameterizedType) type).getRawType());
+        return type instanceof ParameterizedType && isListType((ParameterizedType) type);
     }
 
     /**
@@ -234,10 +247,11 @@ public final class Types {
      * @return <code>ParametrizedType</code> representation of raw type
      *         <code>Augmentable</code> with actual parameter
      *         <code>valueType</code>
+     * @deprecated Use {@link BindingTypes#augmentable(Type)} instead.
      */
+    @Deprecated(forRemoval = true)
     public static @NonNull ParameterizedType augmentableTypeFor(final Type valueType) {
-        final Type augmentable = typeForClass(Augmentable.class);
-        return parameterizedTypeFor(augmentable, valueType);
+        return BindingTypes.augmentable(valueType);
     }
 
     /**
@@ -251,8 +265,7 @@ public final class Types {
      *         <code>valueType</code>
      */
     public static @NonNull ParameterizedType augmentationTypeFor(final Type valueType) {
-        final Type augmentation = typeForClass(Augmentation.class);
-        return parameterizedTypeFor(augmentation, valueType);
+        return parameterizedTypeFor(AUGMENTATION, valueType);
     }
 
     public static @Nullable String getOuterClassName(final Type valueType) {