Class BasicMethodLink

java.lang.Object
org.tudalgo.algoutils.tutor.general.reflections.BasicLink
org.tudalgo.algoutils.tutor.general.reflections.BasicMethodLink
All Implemented Interfaces:
Identifiable, Stringifiable, Link, MethodLink, WithCtElement, WithModifiers, WithName, WithType, WithTypeList

public class BasicMethodLink extends BasicLink implements MethodLink, WithCtElement
A basic implementation of a method link.
  • Method Details

    • of

      public static BasicMethodLink of(Method method)
    • typeList

      public List<BasicTypeLink> typeList()
      Description copied from interface: WithTypeList

      Returns the list of this link.

      Specified by:
      typeList in interface WithTypeList
      Returns:
      the list of types
    • returnType

      public BasicTypeLink returnType()
      Description copied from interface: MethodLink

      Returns the return type of the method linked by this method link.

      Specified by:
      returnType in interface MethodLink
      Returns:
      the return type
    • identifier

      public String identifier()
      Description copied from interface: Identifiable

      Returns the identifier of this identifiable object.

      Specified by:
      identifier in interface Identifiable
      Specified by:
      identifier in interface WithName
      Returns:
      the identifier
    • invokeStatic

      public <T> T invokeStatic(Object... args) throws Exception
      Description copied from interface: MethodLink

      Invokes the method linked by this method link with the given arguments.

      Specified by:
      invokeStatic in interface MethodLink
      Type Parameters:
      T - the type of the return value
      Parameters:
      args - the arguments
      Returns:
      the return value
      Throws:
      Exception
    • invoke

      public <T> T invoke(Object instance, Object... args) throws Exception
      Description copied from interface: MethodLink

      Invokes the method linked by this method link on the given instance with the given arguments.

      Specified by:
      invoke in interface MethodLink
      Type Parameters:
      T - the type of the return value
      Parameters:
      instance - the instance
      args - the arguments
      Returns:
      the return value
      Throws:
      Exception
    • reflection

      public Method reflection()
      Description copied from interface: MethodLink
      Returns the actual method behind this method link.
      Specified by:
      reflection in interface Link
      Specified by:
      reflection in interface MethodLink
      Returns:
      the method
    • type

      public BasicTypeLink type()
      Description copied from interface: WithType

      Returns the type of this link.

      Specified by:
      type in interface WithType
      Returns:
      the type
    • getCtElement

      public spoon.reflect.declaration.CtMethod<?> getCtElement()
      Description copied from interface: WithCtElement
      Returns the CtElement associated with the element behind this link.
      Specified by:
      getCtElement in interface WithCtElement
      Returns:
      the CtElement