Class ExecutableInfo

java.lang.Object
org.apache.juneau.reflect.ExecutableInfo
Direct Known Subclasses:
ConstructorInfo, MethodInfo

public abstract class ExecutableInfo extends Object
Contains common methods between ConstructorInfo and MethodInfo.
See Also:
  • Constructor Details

    • ExecutableInfo

      protected ExecutableInfo(ClassInfo declaringClass, Executable e)
      Constructor.
      Parameters:
      declaringClass - The class that declares this method or constructor.
      e - The constructor or method that this info represents.
  • Method Details

    • getDeclaringClass

      public final ClassInfo getDeclaringClass()
      Returns metadata about the class that declared this method or constructor.
      Returns:
      Metadata about the class that declared this method or constructor.
    • isConstructor

      public final boolean isConstructor()
      Returns true if this executable represents a Constructor.
      Returns:
      true if this executable represents a Constructor and can be cast to ConstructorInfo. false if this executable represents a Method and can be cast to MethodInfo.
    • getParamCount

      public final int getParamCount()
      Returns the number of parameters in this executable.

      Same as calling Executable.getParameterCount().

      Returns:
      The number of parameters in this executable.
    • hasParams

      public final boolean hasParams()
      Returns true if this executable has at least one parameter.

      Same as calling Executable.getParameterCount() and comparing with zero.

      Returns:
      true if this executable has at least one parameter.
    • hasNoParams

      public final boolean hasNoParams()
      Returns true if this executable has no parameters.

      Same as calling Executable.getParameterCount() and comparing with zero.

      Returns:
      true if this executable has no parameters.
    • hasNumParams

      public final boolean hasNumParams(int number)
      Returns true if this executable has this number of arguments.

      Same as calling Executable.getParameterCount() and comparing the count.

      Parameters:
      number - The number of expected arguments.
      Returns:
      true if this executable has this number of arguments.
    • getParams

      public final List<ParamInfo> getParams()
      Returns the parameters defined on this executable.

      Same as calling Executable.getParameters() but wraps the results

      Returns:
      An array of parameter information, never null.
    • forEachParam

      Performs an action on every parameter that matches the specified filter.
      Parameters:
      filter - The filter, can be null.
      action - The action to perform.
      Returns:
      This object.
    • getParam

      public final ParamInfo getParam(int index)
      Returns parameter information at the specified index.
      Parameters:
      index - The parameter index.
      Returns:
      The parameter information, never null.
    • getParamTypes

      public final List<ClassInfo> getParamTypes()
      Returns the parameter types on this executable.
      Returns:
      The parameter types on this executable.
    • getParamType

      public final ClassInfo getParamType(int index)
      Returns the parameter type of the parameter at the specified index.
      Parameters:
      index - The parameter index.
      Returns:
      The parameter type of the parameter at the specified index.
    • getRawParamTypes

      public final List<Class<?>> getRawParamTypes()
      Returns the raw parameter types on this executable.
      Returns:
      The raw parameter types on this executable.
    • getRawParamType

      public final Class<?> getRawParamType(int index)
      Returns the raw parameter type of the parameter at the specified index.
      Parameters:
      index - The parameter index.
      Returns:
      The raw parameter type of the parameter at the specified index.
    • getRawGenericParamTypes

      Returns the raw generic parameter types on this executable.
      Returns:
      The raw generic parameter types on this executable.
    • getRawGenericParamType

      public final Type getRawGenericParamType(int index)
      Returns the raw generic parameter type of the parameter at the specified index.
      Parameters:
      index - The parameter index.
      Returns:
      The raw generic parameter type of the parameter at the specified index.
    • getRawParameters

      public final List<Parameter> getRawParameters()
      Returns an array of raw Parameter objects that represent all the parameters to the underlying executable represented by this object.
      Returns:
      An array of raw Parameter objects, or an empty array if executable has no parameters.
      See Also:
    • getRawParameter

      public final Parameter getRawParameter(int index)
      Returns the raw Parameter object that represents the parameter at the specified index.
      Parameters:
      index - The parameter index.
      Returns:
      The raw Parameter object that represents the parameter at the specified index.
      See Also:
    • forEachParameterAnnotation

      public final <A extends Annotation> ExecutableInfo forEachParameterAnnotation(int index, Class<A> type, Predicate<A> predicate, Consumer<A> consumer)
      Performs an action on all matching parameter annotations at the specified parameter index.
      Type Parameters:
      A - The annotation type.
      Parameters:
      index - The parameter index.
      type - The annotation type.
      predicate - The predicate.
      consumer - The consumer.
      Returns:
      This object.
    • getExceptionTypes

      public final List<ClassInfo> getExceptionTypes()
      Returns the exception types on this executable.
      Returns:
      The exception types on this executable.
    • isAll

      public final boolean isAll(ReflectFlags... flags)
      Returns true if all specified flags are applicable to this method.
      Parameters:
      flags - The flags to test for.
      Returns:
      true if all specified flags are applicable to this method.
    • is

      public final boolean is(ReflectFlags... flags)
      Returns true if all specified flags are applicable to this field.
      Parameters:
      flags - The flags to test for.
      Returns:
      true if all specified flags are applicable to this field.
    • isAny

      public final boolean isAny(ReflectFlags... flags)
      Returns true if all specified flags are applicable to this method.
      Parameters:
      flags - The flags to test for.
      Returns:
      true if all specified flags are applicable to this method.
    • hasParamTypes

      public final boolean hasParamTypes(Class<?>... args)
      Returns true if this method has the specified arguments.
      Parameters:
      args - The arguments to test for.
      Returns:
      true if this method has this arguments in the exact order.
    • hasParamTypes

      public final boolean hasParamTypes(ClassInfo... args)
      Returns true if this method has the specified arguments.
      Parameters:
      args - The arguments to test for.
      Returns:
      true if this method has this arguments in the exact order.
    • hasMatchingParamTypes

      public final boolean hasMatchingParamTypes(Class<?>... args)
      Returns true if this method has the specified argument parent classes.
      Parameters:
      args - The arguments to test for.
      Returns:
      true if this method has this arguments in the exact order.
    • hasMatchingParamTypes

      public final boolean hasMatchingParamTypes(ClassInfo... args)
      Returns true if this method has the specified argument parent classes.
      Parameters:
      args - The arguments to test for.
      Returns:
      true if this method has this arguments in the exact order.
    • hasFuzzyParamTypes

      public final boolean hasFuzzyParamTypes(Class<?>... args)
      Returns true if this method has at most only this arguments in any order.
      Parameters:
      args - The arguments to test for.
      Returns:
      true if this method has at most only this arguments in any order.
    • fuzzyArgsMatch

      public final int fuzzyArgsMatch(Class<?>... argTypes)
      Returns how well this method matches the specified arg types.

      The number returned is the number of method arguments that match the passed in arg types.
      Returns -1 if the method cannot take in one or more of the specified arguments.

      Parameters:
      argTypes - The arg types to check against.
      Returns:
      How many parameters match or -1 if method cannot handle one or more of the arguments.
    • fuzzyArgsMatch

      public final int fuzzyArgsMatch(Object... argTypes)
      Returns how well this method matches the specified arg types.

      The number returned is the number of method arguments that match the passed in arg types.
      Returns -1 if the method cannot take in one or more of the specified arguments.

      Parameters:
      argTypes - The arg types to check against.
      Returns:
      How many parameters match or -1 if method cannot handle one or more of the arguments.
    • hasFuzzyParamTypes

      public final boolean hasFuzzyParamTypes(ClassInfo... args)
      Returns true if this method has at most only this arguments in any order.
      Parameters:
      args - The arguments to test for.
      Returns:
      true if this method has at most only this arguments in any order.
    • fuzzyArgsMatch

      public final int fuzzyArgsMatch(ClassInfo... argTypes)
      Returns how well this method matches the specified arg types.

      The number returned is the number of method arguments that match the passed in arg types.
      Returns -1 if the method cannot take in one or more of the specified arguments.

      Parameters:
      argTypes - The arg types to check against.
      Returns:
      How many parameters match or -1 if method cannot handle one or more of the arguments.
    • isDeprecated

      public final boolean isDeprecated()
      Returns true if this method has the @Deprecated annotation on it.
      Returns:
      true if this method has the @Deprecated annotation on it.
    • isNotDeprecated

      public final boolean isNotDeprecated()
      Returns true if this method doesn't have the @Deprecated annotation on it.
      Returns:
      true if this method doesn't have the @Deprecated annotation on it.
    • isAbstract

      public final boolean isAbstract()
      Returns true if this method is abstract.
      Returns:
      true if this method is abstract.
    • isNotAbstract

      public final boolean isNotAbstract()
      Returns true if this method is not abstract.
      Returns:
      true if this method is not abstract.
    • isPublic

      public final boolean isPublic()
      Returns true if this method is public.
      Returns:
      true if this method is public.
    • isNotPublic

      public final boolean isNotPublic()
      Returns true if this method is not public.
      Returns:
      true if this method is not public.
    • isProtected

      public final boolean isProtected()
      Returns true if this method is protected.
      Returns:
      true if this method is protected.
    • isNotProtected

      public final boolean isNotProtected()
      Returns true if this method is not protected.
      Returns:
      true if this method is not protected.
    • isStatic

      public final boolean isStatic()
      Returns true if this method is static.
      Returns:
      true if this method is static.
    • isNotStatic

      public final boolean isNotStatic()
      Returns true if this method is not static.
      Returns:
      true if this method is not static.
    • accessible

      Attempts to call x.setAccessible(true) and quietly ignores security exceptions.
      Returns:
      This object.
    • setAccessible

      public final boolean setAccessible()
      Attempts to call x.setAccessible(true) and quietly ignores security exceptions.
      Returns:
      true if call was successful.
    • isVisible

      public final boolean isVisible(Visibility v)
      Identifies if the specified visibility matches this method.
      Parameters:
      v - The visibility to validate against.
      Returns:
      true if this visibility matches the modifier attribute of this method.
    • hasName

      public final boolean hasName(String name)
      Returns true if this method has this name.
      Parameters:
      name - The name to test for.
      Returns:
      true if this method has this name.
    • hasName

      public final boolean hasName(String... names)
      Returns true if this method has a name in the specified list.
      Parameters:
      names - The names to test for.
      Returns:
      true if this method has one of the names.
    • hasName

      public final boolean hasName(Set<String> names)
      Returns true if this method has a name in the specified set.
      Parameters:
      names - The names to test for.
      Returns:
      true if this method has one of the names.
    • getFullName

      public final String getFullName()
      Returns the full name of this executable.
      Examples:
      • "com.foo.MyClass.get(java.util.String)" - Method.
      • "com.foo.MyClass(java.util.String)" - Constructor.
      Returns:
      The underlying executable name.
    • getShortName

      public final String getShortName()
      Returns the short name of this executable.
      Examples:
      • "MyClass.get(String)" - Method.
      • "MyClass(String)" - Constructor.
      Returns:
      The underlying executable name.
    • getSimpleName

      public final String getSimpleName()
      Returns the simple name of the underlying method.
      Returns:
      The simple name of the underlying method;
    • toString

      public String toString()
      Overrides:
      toString in class Object