Record Class AnnotatedMethodHandle<T>

java.lang.Object
java.lang.Record
com.thewinterframework.utils.reflect.AnnotatedMethodHandle<T>
Type Parameters:
T - The annotation type.

public record AnnotatedMethodHandle<T>(Method reflect, MethodHandle handle, T annotation, List<com.google.inject.Key<?>> parameters) extends Record
Represents a method handle annotated with a specific annotation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AnnotatedMethodHandle(Method reflect, MethodHandle handle, T annotation, List<com.google.inject.Key<?>> parameters)
    Creates an instance of a AnnotatedMethodHandle record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    annotatedWith(Class<A> annotationType)
    Returns an AnnotatedMethodHandle for the specified annotation type.
    Returns the value of the annotation record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the handle record component.
    final int
    Returns a hash code value for this object.
    void
    invoke(Class<?> clazz, com.google.inject.Injector injector)
    Invokes the method handle with the given parameters.
    List<com.google.inject.Key<?>>
    Returns the value of the parameters record component.
    Returns the value of the reflect record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AnnotatedMethodHandle

      public AnnotatedMethodHandle(Method reflect, MethodHandle handle, T annotation, List<com.google.inject.Key<?>> parameters)
      Creates an instance of a AnnotatedMethodHandle record class.
      Parameters:
      reflect - the value for the reflect record component
      handle - the value for the handle record component
      annotation - the value for the annotation record component
      parameters - the value for the parameters record component
  • Method Details

    • invoke

      public void invoke(Class<?> clazz, com.google.inject.Injector injector) throws Throwable
      Invokes the method handle with the given parameters.
      Parameters:
      clazz - The class to invoke the method on.
      injector - The injector to get the instances from.
      Throws:
      Throwable - If an error occurs while invoking the method.
    • annotatedWith

      public <A extends Annotation> AnnotatedMethodHandle<A> annotatedWith(Class<A> annotationType)
      Returns an AnnotatedMethodHandle for the specified annotation type.
      Type Parameters:
      A - The type of the annotation.
      Parameters:
      annotationType - The annotation type to retrieve.
      Returns:
      An AnnotatedMethodHandle for the specified annotation type.
      Throws:
      IllegalArgumentException - If the method is not annotated with the specified annotation type.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • reflect

      public Method reflect()
      Returns the value of the reflect record component.
      Returns:
      the value of the reflect record component
    • handle

      public MethodHandle handle()
      Returns the value of the handle record component.
      Returns:
      the value of the handle record component
    • annotation

      public T annotation()
      Returns the value of the annotation record component.
      Returns:
      the value of the annotation record component
    • parameters

      public List<com.google.inject.Key<?>> parameters()
      Returns the value of the parameters record component.
      Returns:
      the value of the parameters record component