Class LambdaType<T>

java.lang.Object
org.lanternpowered.lmbda.LambdaType<T>

public abstract class LambdaType<@NonNull T>
extends java.lang.Object
Represents a function interface or abstract class that can be be implemented by a generated function.
  • Constructor Summary

    Constructors
    Constructor Description
    LambdaType()
    Constructs a new LambdaType.
  • Method Summary

    Modifier and Type Method Description
    protected @NonNull java.lang.Object clone()  
    @NonNull LambdaType<T> defineClassesWith​(@NonNull java.lang.invoke.MethodHandles.Lookup defineLookup)
    Constructs a new LambdaType where that will define the implementation class using the provided lookup.
    boolean equals​(@Nullable java.lang.Object obj)  
    protected void finalize()
    Deprecated.
    @NonNull java.lang.Class<T> getFunctionClass()
    Gets the function class that will be implemented.
    @NonNull java.lang.reflect.Type getFunctionType()
    Gets the function type that will be implemented.
    @NonNull java.lang.reflect.Method getMethod()
    Gets the Method that will be implemented when generating a function for this LambdaType.
    int hashCode()  
    static <@NonNull T>
    @NonNull LambdaType<T>
    of​(@NonNull java.lang.Class<@NonNull T> functionType)
    Constructs a new LambdaType from the given function interface or abstract class.
    static <@NonNull T>
    @NonNull LambdaType<T>
    of​(@NonNull java.lang.reflect.Type functionType)
    Constructs a new LambdaType from the given function interface or abstract class type.
    @NonNull java.lang.String toString()  

    Methods inherited from class java.lang.Object

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

    • LambdaType

      public LambdaType()
      Constructs a new LambdaType.

      The generic signature from the extended class will be used to determine the functional interface to implement. If it's not resolved, a IllegalStateException can be expected.

  • Method Details

    • of

      public static <@NonNull T> @NonNull LambdaType<T> of​(@NonNull java.lang.Class<@NonNull T> functionType)
      Constructs a new LambdaType from the given function interface or abstract class.

      A functional abstract class is either a interface or a "abstract" class that has a no-arg constructor. In both cases is only one abstract method allowed.

      Type Parameters:
      T - The type of the function type
      Parameters:
      functionType - The function type
      Returns:
      The lambda type
      Throws:
      java.lang.IllegalArgumentException - If no valid functional method could be found
    • of

      public static <@NonNull T> @NonNull LambdaType<T> of​(@NonNull java.lang.reflect.Type functionType)
      Constructs a new LambdaType from the given function interface or abstract class type.

      A functional abstract class is either a interface or a "abstract" class that has a no-arg constructor. In both cases is only one abstract method allowed.

      The generic signature of the given Type will be retained by a resulting function.

      Type Parameters:
      T - The type of the function
      Parameters:
      functionType - The function type
      Returns:
      The lambda type
      Throws:
      java.lang.IllegalArgumentException - If no valid functional method could be found
    • defineClassesWith

      public final @NonNull LambdaType<T> defineClassesWith​(@NonNull java.lang.invoke.MethodHandles.Lookup defineLookup)
      Constructs a new LambdaType where that will define the implementation class using the provided lookup.

      When the functional interface/abstract class isn't public, or the abstract method isn't, then should the lookup be defined explicitly. Its implementation class needs the proper access in order to be implemented successfully. This can be in the same package or a different one depending on what is desired.

      Parameters:
      defineLookup - The define lookup
      Returns:
      The new lambda type
    • getFunctionClass

      public final @NonNull java.lang.Class<T> getFunctionClass()
      Gets the function class that will be implemented.
      Returns:
      The function class
    • getFunctionType

      public final @NonNull java.lang.reflect.Type getFunctionType()
      Gets the function type that will be implemented.
      Returns:
      The function type
    • getMethod

      public final @NonNull java.lang.reflect.Method getMethod()
      Gets the Method that will be implemented when generating a function for this LambdaType.
      Returns:
      The method
    • toString

      public final @NonNull java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • equals

      public final boolean equals​(@Nullable java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • clone

      protected final @NonNull java.lang.Object clone() throws java.lang.CloneNotSupportedException
      Overrides:
      clone in class java.lang.Object
      Throws:
      java.lang.CloneNotSupportedException
    • finalize

      @Deprecated protected final void finalize()
      Deprecated.
      Overrides:
      finalize in class java.lang.Object