Class ParameterGroup

java.lang.Object
nl.pim16aap2.util.reflection.ParameterGroup

public class ParameterGroup extends Object
Represents a group of parameters that describes, for example, the input arguments of a Constructor.

The advantage over using an array of raw Class objects is that these parameters can be marked optional, allowing for greater freedom when searching for a method with a set of parameters.

For example, when providing the types {int.class, boolean.class, float.class} and mark float.class as optional, this set of parameters can be used to match a method void fun(int, boolean) as well as a method void fun(int, boolean, float.

Use ParameterGroup.Builder to create a new instance.

  • Constructor Details

  • Method Details

    • matches

      @CheckReturnValue @Contract(pure=true) public boolean matches(Class<?>... types)
      Checks if a set of types matches the current set of parameters.

      Any optional parameters may be skipped if that helps to achieve a match.

      Parameters:
      types - The types to compare the parameters against.
      Returns:
      True if the provided types match the defined parameters.
    • toString

      public String toString()
      Overrides:
      toString in class Object