Interface CallableArgsReturns<T,Arg>

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface CallableArgsReturns<T,Arg>
Interface for executing code with arguments that returns a value. A CallableArgsReturns object can be constructed inside an object's methods so that otherwise hidden fields and methods are accessible. For example

  Map<String, CallableArgsReturns<Integer,Integer>> table = ...;
  void foo(final int i) {
     CallableArgsReturns<Integer> callable
       = new CallableArgsReturns<Integer,Integer>() {
                 public Integer call(Integer... args) {
                     int j = (args.length == 0)? 0: args[0];
                     return Integer.valueOf(i + j);
                 }
             };
     table.put("foo", callable);
 }

 void bar(int j) {
     System.out.println(table.get("foo").call(Integer.valueOf(j)));
  }
 
  • Method Summary

    Modifier and Type
    Method
    Description
    call(Arg... args)
    The method to call.
  • Method Details

    • call

      T call(Arg... args)
      The method to call.
      Parameters:
      args - additional arguments supplied by the caller when this method is called
      Returns:
      an object of type T providing the results of the call