java.lang.Object
org.mule.runtime.extension.api.declaration.type.TypeUtils

public final class TypeUtils extends Object
Utility class to handle Java types and their relationship with the MetadataType model
Since:
1.0
  • Method Details

    • getParameterFields

      public static Collection<Field> getParameterFields(Class<?> declaringType)
      Returns all the Fields in the given declaringType which are annotated with Parameter but also do not have the Ignore one.

      The introspection also includes parent classes.

      Parameters:
      declaringType - the class to introspect.
      Returns:
      a Collection of fields. May be empty but will never be null
    • getAllFields

      public static Collection<Field> getAllFields(Class<?> declaringType)
      Returns all the Fields in the given declaringType.

      The introspection also includes parent classes.

      Parameters:
      declaringType - the class to introspect.
      Returns:
      a Collection of fields. May be empty but will never be null
    • getAllSuperClasses

      public static Collection<Class<?>> getAllSuperClasses(Class<?> type)
      Returns all the superclasses of the given type, without including Object
      Parameters:
      type - a type
      Returns:
      all the type's super classes
    • getAlias

      @Deprecated public static String getAlias(Field field)
      Deprecated.
      since 1.5.0 use JavaParserUtils.getAlias(Field) instead
      Checks the given field for the Alias annotation. If present, Alias.value() is returned. Otherwise, Field.getName() is returned.
      Parameters:
      field - a Field
      Returns:
      the field's alias
    • isParameter

      public static boolean isParameter(Field field)
      Checks if a field is a parameter
      Parameters:
      field - a Field
      Returns:
      true if the Field contains either the annotation Parameter or Parameter
      Since:
      4.5
    • isParameterGroup

      public static boolean isParameterGroup(Field field)
      Checks if a field is a parameter group
      Parameters:
      field - a Field
      Returns:
      true if the Field contains either the annotation ParameterGroup or ParameterGroup
      Since:
      4.5
    • isOptional

      public static boolean isOptional(Field field)
      Checks if a field is optional or not
      Parameters:
      field - the field to check
      Returns:
      whether the field is optional or not
      Since:
      4.5
    • getDisplayName

      public static Optional<String> getDisplayName(Field field)
      Returns the display name of the given Field if either annotation DisplayName or DisplayName are present
      Parameters:
      field - the Field to be introspected
      Returns:
      Optional containing the display name string if either DisplayName or DisplayName are present.
      Since:
      4.5
    • getSummaryValue

      public static Optional<String> getSummaryValue(Field field)
      Returns the summary of the given Field if either annotation Summary or Summary are present
      Parameters:
      field - the Field to be introspected
      Returns:
      Optional containing the summary string if either Summary or Summary are present.
      Since:
      4.5
    • getExampleValue

      public static Optional<String> getExampleValue(Field field)
      Returns the example of the given Field if either annotation Example or Example are present
      Parameters:
      field - the Field to be introspected
      Returns:
      Optional containing the example string if either Example or Example are present.
      Since:
      4.5
    • getPathModel

      public static Optional<org.mule.runtime.api.meta.model.display.PathModel> getPathModel(Field field)
      Returns the PathModel of the given Field if either annotation Path or FilePath are present
      Parameters:
      field - the Field to be introspected
      Returns:
      Optional containing the PathModel if either Path or FilePath are present.
      Since:
      4.5
    • getClassValueModel

      public static Optional<org.mule.runtime.api.meta.model.display.ClassValueModel> getClassValueModel(Field field)
      Returns the ClassValueModel of the given Field if either annotation ClassValue or ClassValue are present
      Parameters:
      field - the Field to be introspected
      Returns:
      Optional containing the ClassValueModel if either ClassValue or ClassValue are present.
      Since:
      4.5
    • getPlacementValue

      public static Optional<org.mule.runtime.api.util.Pair<Integer,String>> getPlacementValue(Field field)
      Returns the order and tab of the given Field if either annotation Placement or Placement are present
      Parameters:
      field - the Field to be introspected
      Returns:
      Optional containing a java.util.Optional<Pair<Integer, String>> with the order and tab placement if either Placement or Placement are present.
      Since:
      4.5
    • isTextField

      public static boolean isTextField(Field field)
      Checks if the given Field is annotated with either Text or Text
      Parameters:
      field - the Field to be introspected
      Returns:
      true if the given Field is annotated with either Text or Text
      Since:
      4.5
    • isPasswordField

      public static boolean isPasswordField(Field field)
      Checks if the given Field is annotated with Password
      Parameters:
      field - the Field to be introspected
      Returns:
      true if the given Field is annotated Password
      Since:
      4.5
    • isQueryField

      public static boolean isQueryField(Field field)
      Checks if the given Field is annotated with Query
      Parameters:
      field - the Field to be introspected
      Returns:
      true if the given Field is annotated with Query
      Since:
      4.5
    • isAnnotationPresentOnField

      public static <R extends Annotation> boolean isAnnotationPresentOnField(Field field, Class<R> annotationClass)
    • isAnnotationPresentOnField

      public static <R extends Annotation, S extends Annotation> boolean isAnnotationPresentOnField(Field field, Class<R> legacyAnnotationClass, Class<S> sdkAnnotationClass)