Class Function

java.lang.Object
org.springframework.data.spel.spi.Function

public class Function extends Object
Value object to represent a function. Can either be backed by a static Method invocation (see Function(Method)) or a method invocation on an instance (see Function(Method, Object).
Since:
1.9
Author:
Thomas Darimont, Oliver Gierke, Jens Schauder, Johannes Englmeier
  • Constructor Details

    • Function

      public Function(Method method)
      Creates a new Function to statically invoke the given Method.
      Parameters:
      method -
    • Function

      public Function(Method method, @Nullable Object target)
      Creates a new Function for the given method on the given target instance.
      Parameters:
      method - must not be null.
      target - can be null, if so, the method
  • Method Details

    • invoke

      public Object invoke(Object[] arguments) throws Exception
      Invokes the function with the given arguments.
      Parameters:
      arguments - must not be null.
      Returns:
      Throws:
      Exception
    • getName

      public String getName()
      Returns the name of the function.
      Returns:
    • getDeclaringClass

      public Class<?> getDeclaringClass()
      Returns the type declaring the Function.
      Returns:
    • supports

      public boolean supports(List<org.springframework.core.convert.TypeDescriptor> argumentTypes)
      Returns true if the function can be called with the given argumentTypes.
      Parameters:
      argumentTypes -
      Returns:
    • getParameterCount

      public int getParameterCount()
      Returns the number of parameters required by the underlying method.
      Returns:
    • supportsExact

      public boolean supportsExact(List<org.springframework.core.convert.TypeDescriptor> argumentTypes)
      Checks if the encapsulated method has exactly the argument types as those passed as an argument.
      Parameters:
      argumentTypes - a list of TypeDescriptors to compare with the argument types of the method
      Returns:
      true if the types are equal, false otherwise.
    • isSignatureEqual

      public boolean isSignatureEqual(Function other)
      Checks whether this Function has the same signature as another Function.
      Parameters:
      other - the Function to compare this with.
      Returns:
      true if name and argument list are the same.