Add BindingTypes.augmentation()
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / util / Types.java
index 2dec3dae45f8b07373058d1d9cd6cfc4eeb953b3..eefeaa26b035b2fa9456d68c0ab7ee7168db7924 100644 (file)
@@ -34,8 +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;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
@@ -65,9 +63,6 @@ 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 AUGMENTABLE = typeForClass(Augmentable.class);
-    private static final @NonNull ConcreteType AUGMENTATION = typeForClass(Augmentation.class);
-
     /**
      * It is not desirable to create instance of this class.
      */
@@ -156,6 +151,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.
@@ -241,9 +244,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) {
-        return parameterizedTypeFor(AUGMENTABLE, valueType);
+        return BindingTypes.augmentable(valueType);
     }
 
     /**
@@ -252,12 +257,14 @@ public final class Types {
      * is <code>valueType</code>.
      *
      * @param valueType JAVA <code>Type</code> with actual parameter
-     * @return <code>ParametrizedType</code> reprezentation of raw type
+     * @return <code>ParametrizedType</code> representation of raw type
      *         <code>Augmentation</code> with actual parameter
      *         <code>valueType</code>
+     * @deprecated Use {@link BindingTypes#augmentation(Type)} instead.
      */
+    @Deprecated(forRemoval = true)
     public static @NonNull ParameterizedType augmentationTypeFor(final Type valueType) {
-        return parameterizedTypeFor(AUGMENTATION, valueType);
+        return BindingTypes.augmentation(valueType);
     }
 
     public static @Nullable String getOuterClassName(final Type valueType) {