Package org.openrewrite.java.tree
Class TypeUtils
- java.lang.Object
-
- org.openrewrite.java.tree.TypeUtils
-
public class TypeUtils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JavaType.ArrayasArray(@Nullable JavaType type)static JavaType.ClassasClass(@Nullable JavaType type)static JavaType.FullyQualifiedasFullyQualified(@Nullable JavaType type)static JavaType.GenericTypeVariableasGeneric(@Nullable JavaType type)static JavaType.ParameterizedasParameterized(@Nullable JavaType type)static JavaType.PrimitiveasPrimitive(@Nullable JavaType type)static java.util.Optional<JavaType.Method>findDeclaredMethod(JavaType.FullyQualified clazz, java.lang.String name, java.util.List<JavaType> argumentTypes)static java.util.Optional<JavaType.Method>findOverriddenMethod(JavaType.Method method)Given a method type, searches the declaring type's parent and interfaces for a method with the same name and signature.static booleanfullyQualifiedNamesAreEqual(@Nullable java.lang.String fqn1, @Nullable java.lang.String fqn2)static booleanisAssignableTo(@Nullable JavaType to, @Nullable JavaType from)static booleanisAssignableTo(java.lang.String to, @Nullable JavaType from)static booleanisOfClassType(@Nullable JavaType type, java.lang.String fqn)static booleanisOfType(@Nullable JavaType type1, @Nullable JavaType type2)static booleanisOverride(JavaType.Method method)Determine if a method overrides a method from a superclass or interface.static booleanisString(@Nullable JavaType type)
-
-
-
Method Detail
-
isString
public static boolean isString(@Nullable @Nullable JavaType type)
-
fullyQualifiedNamesAreEqual
public static boolean fullyQualifiedNamesAreEqual(@Nullable @Nullable java.lang.String fqn1, @Nullable @Nullable java.lang.String fqn2)
-
isOfType
public static boolean isOfType(@Nullable @Nullable JavaType type1, @Nullable @Nullable JavaType type2)
-
isOfClassType
public static boolean isOfClassType(@Nullable @Nullable JavaType type, java.lang.String fqn)
-
isAssignableTo
public static boolean isAssignableTo(@Nullable @Nullable JavaType to, @Nullable @Nullable JavaType from)
-
isAssignableTo
public static boolean isAssignableTo(java.lang.String to, @Nullable @Nullable JavaType from)
-
asClass
@Nullable public static JavaType.Class asClass(@Nullable @Nullable JavaType type)
-
asParameterized
@Nullable public static JavaType.Parameterized asParameterized(@Nullable @Nullable JavaType type)
-
asArray
@Nullable public static JavaType.Array asArray(@Nullable @Nullable JavaType type)
-
asGeneric
@Nullable public static JavaType.GenericTypeVariable asGeneric(@Nullable @Nullable JavaType type)
-
asPrimitive
@Nullable public static JavaType.Primitive asPrimitive(@Nullable @Nullable JavaType type)
-
asFullyQualified
@Nullable public static JavaType.FullyQualified asFullyQualified(@Nullable @Nullable JavaType type)
-
isOverride
public static boolean isOverride(@Nullable JavaType.Method method)Determine if a method overrides a method from a superclass or interface.- Returns:
- `true` if a superclass or implemented interface declares a non-private method with matching signature. `false` if a match is not found or the method, declaring type, or generic signature is null.
-
findOverriddenMethod
public static java.util.Optional<JavaType.Method> findOverriddenMethod(@Nullable JavaType.Method method)
Given a method type, searches the declaring type's parent and interfaces for a method with the same name and signature.NOTE: This method will return an empty optional if the method, the method's declaring type, or the method's generic signature is null.
- Returns:
- An optional overridden method type declared in the parent.
-
findDeclaredMethod
public static java.util.Optional<JavaType.Method> findDeclaredMethod(@Nullable JavaType.FullyQualified clazz, java.lang.String name, java.util.List<JavaType> argumentTypes)
-
-