Interface ExecutableCreator

All Superinterfaces:
AnnotatableCreator, MethodTyped, ModifiableCreator, Typed, TypeParameterizedCreator
All Known Subinterfaces:
AbstractMethodCreator, ConstructorCreator, InstanceExecutableCreator, InstanceMethodCreator, MethodCreator, StaticExecutableCreator, StaticMethodCreator

public sealed interface ExecutableCreator extends MethodTyped, TypeParameterizedCreator, ModifiableCreator permits InstanceExecutableCreator, MethodCreator, StaticExecutableCreator (not exhaustive)
A creator for an executable (i.e. something that can be called with arguments).
  • Method Details

    • type

      Returns the type descriptor of this executable (not null).
      Specified by:
      type in interface MethodTyped
      Specified by:
      type in interface Typed
      Returns:
      the type descriptor of this executable (not null)
    • setType

      void setType(MethodTypeDesc desc)
      Establish the type of this executable. Created parameters will be required to conform to this type. If some parameters have already been created, then their types must match their corresponding types in the given descriptor.
      Parameters:
      desc - the executable type (must not be null)
      Throws:
      IllegalStateException - if the executable type has already been established
      IllegalArgumentException - if some parameters are already defined, and their types do not match the given type descriptor
    • parameter

      ParamVar parameter(String name, Consumer<ParamCreator> builder)
      Add a parameter. If the method type has not yet been established, it is changed to include the new parameter. If the method type is already set, then any type given to the new parameter must match the type of the next parameter of the method type.
      Parameters:
      name - the parameter name (must not be null)
      builder - the parameter builder (must not be null)
      Returns:
      the parameter variable (not null)
      Throws:
      IllegalArgumentException - if the type does not match the corresponding parameter type in the established method type, or if the number of parameters exceeds the number of parameters in the established type
    • parameter

      ParamVar parameter(String name, int position, Consumer<ParamCreator> builder)
      Add a parameter at the given position. If the method type has not yet been established, it is changed to include the new parameter. If the method type is already set, then any type given to the new parameter must match the type of the corresponding parameter of the method type.
      Parameters:
      name - the parameter name (must not be null)
      position - the parameter position, counting up from zero (not including this)
      builder - the parameter builder (must not be null)
      Returns:
      the parameter variable (not null)
      Throws:
      IllegalArgumentException - if the type does not match the corresponding parameter type in the established method type, or if the number of parameters exceeds the number of parameters in the established type
      IndexOutOfBoundsException - if the parameter position is out of range
    • parameter

      default ParamVar parameter(String name)
      Add a parameter. If the method type has not yet been established, an exception is thrown. If the method type is already set, then the new parameter will be given the type of the next parameter of the method type.
      Parameters:
      name - the parameter name (must not be null)
      Returns:
      the parameter variable (not null)
      Throws:
      IllegalStateException - if the type of this executable has not yet been established, or if the parameter with the next position has already been declared
      IllegalArgumentException - if the type does not match the corresponding parameter type in the established method type, or if the number of parameters exceeds the number of parameters in the established type
    • parameter

      default ParamVar parameter(String name, int position)
      Add a parameter at the given position. If the method type has not yet been established, an exception is thrown. If the method type is already set, then the new parameter will be given the type of the next parameter of the method type.
      Parameters:
      name - the parameter name (must not be null)
      position - the parameter position, counting up from zero (not including this)
      Returns:
      the parameter variable (not null)
      Throws:
      IllegalStateException - if the type of this executable has not yet been established, or if the parameter with the given position has already been declared
      IllegalArgumentException - if the type does not match the corresponding parameter type in the established method type, or if the number of parameters exceeds the number of parameters in the established type
      IndexOutOfBoundsException - if the parameter position is out of range
    • parameter

      default ParamVar parameter(String name, GenericType type)
      Add a parameter. If the method type has not yet been established, it is changed to include the new parameter. If the method type is already set, then the given type must match the type of the next parameter of the method type.
      Parameters:
      name - the parameter name (must not be null)
      type - the parameter type (must not be null)
      Returns:
      the parameter variable (not null)
      Throws:
      IllegalStateException - if the type of this executable has not yet been established, or if the parameter with the next position has already been declared
      IllegalArgumentException - if the type does not match the corresponding parameter type in the established method type, or if the number of parameters exceeds the number of parameters in the established type
    • parameter

      default ParamVar parameter(String name, int position, GenericType type)
      Add a parameter. If the method type has not yet been established, it is changed to include the new parameter, and the position must correspond to the next unset parameter. If the method type is already set, then the given type must match the type of the corresponding parameter of the method type.
      Parameters:
      name - the parameter name (must not be null)
      type - the parameter type (must not be null)
      Returns:
      the parameter variable (not null)
      Throws:
      IllegalStateException - if the type of this executable has not yet been established, or if the parameter with the given position has already been declared
      IllegalArgumentException - if the type does not match the corresponding parameter type in the established method type, or if the number of parameters exceeds the number of parameters in the established type
      IndexOutOfBoundsException - if the parameter position is out of range
    • parameter

      default ParamVar parameter(String name, ClassDesc type)
      Add a parameter. If the method type has not yet been established, it is changed to include the new parameter. If the method type is already set, then the given type must match the type of the next parameter of the method type.
      Parameters:
      name - the parameter name (must not be null)
      type - the parameter type (must not be null)
      Returns:
      the parameter variable (not null)
      Throws:
      IllegalStateException - if the type of this executable has not yet been established, or if the parameter with the next position has already been declared
      IllegalArgumentException - if the type does not match the corresponding parameter type in the established method type, or if the number of parameters exceeds the number of parameters in the established type
    • parameter

      default ParamVar parameter(String name, int position, ClassDesc type)
      Add a parameter. If the method type has not yet been established, it is changed to include the new parameter, and the position must correspond to the next unset parameter. If the method type is already set, then the given type must match the type of the corresponding parameter of the method type.
      Parameters:
      name - the parameter name (must not be null)
      type - the parameter type (must not be null)
      Returns:
      the parameter variable (not null)
      Throws:
      IllegalStateException - if the type of this executable has not yet been established, or if the parameter with the given position has already been declared
      IllegalArgumentException - if the type does not match the corresponding parameter type in the established method type, or if the number of parameters exceeds the number of parameters in the established type
      IndexOutOfBoundsException - if the parameter position is out of range
    • parameter

      default ParamVar parameter(String name, Class<?> type)
      Add a parameter. If the method type has not yet been established, it is changed to include the new parameter. If the method type is already set, then the given type must match the type of the next parameter of the method type.
      Parameters:
      name - the parameter name (must not be null)
      type - the parameter type (must not be null)
      Returns:
      the parameter variable (not null)
      Throws:
      IllegalStateException - if the type of this executable has not yet been established, or if the parameter with the next position has already been declared
      IllegalArgumentException - if the type does not match the corresponding parameter type in the established method type, or if the number of parameters exceeds the number of parameters in the established type
    • parameter

      default ParamVar parameter(String name, int position, Class<?> type)
      Add a parameter. If the method type has not yet been established, it is changed to include the new parameter, and the position must correspond to the next unset parameter. If the method type is already set, then the given type must match the type of the corresponding parameter of the method type.
      Parameters:
      name - the parameter name (must not be null)
      type - the parameter type (must not be null)
      Returns:
      the parameter variable (not null)
      Throws:
      IllegalStateException - if the type of this executable has not yet been established, or if the parameter with the given position has already been declared
      IllegalArgumentException - if the type does not match the corresponding parameter type in the established method type, or if the number of parameters exceeds the number of parameters in the established type
      IndexOutOfBoundsException - if the parameter position is out of range
    • throws_

      void throws_(GenericType.OfThrows throwableType)
      Declare that this method throws exceptions of the given type.
      Parameters:
      throwableType - the generic exception type (must not be null)
    • throws_

      default void throws_(ClassDesc throwableType)
      Declare that this method throws exceptions of the given type.
      Parameters:
      throwableType - the exception type (must not be null)
    • throws_

      default void throws_(Class<? extends Throwable> throwableType)
      Declare that this method throws exceptions of the given type.
      Parameters:
      throwableType - the exception type (must not be null)
    • varargs

      default void varargs()
      Add the variable arguments modifier flag to this creator.