0 Replies Latest reply on Nov 28, 2018 10:11 PM by Stan Hughes

    BiFunction reference from a string representing classpath of the function (method)

    Stan Hughes

      I am trying to figure out how I can use a string containing the classpath of a method to create a Bifunction reference I can use in a lambda. I may be going about this all wrong - but...

       

      For instance:

       

      If I had the following class:

       

      package com;

       

      public class Greeter {

        public String helloWorld(String firstname,String lastName) {

            return "Hello, "+firstname+" "+lastname;

        }

      }

      How could I create a Bifunction reference from a string so that I could put it into a hashtable:

       

      Hashtable<String,BiFunction<String,String,String>> functions = new Hashtable<>();

      ReferenceToBiFunction ref = GetReferenceToBiFunctionFromString("com.Greeter::helloWorld");

      functions.put("HelloWorld",ref);

       

      Is there a way to do this?