title: How to pass multiple parameters and a function and then execute function with parameters in Java 8?
body: <p>We have this school project where we should make rent-a-car-like java app.</p>
  
  <p>I wrote the following code that just takes some jsonObject properties, calls function depending on the action code and puts some things in jsonObject property. But I reaaally don't like this code repetition pattern...</p>
  
  <pre><code>if(action.equals("REGOPR")) {
      // Register operator
      String user = (String)jsonObject.get("username");
      String pass = (String)jsonObject.get("password");
      if(registerOperator(user, pass))
          jsonObj.put("resp", "Operator successfully registered!");
      else {
          jsonObj.put("status", "fail");
          jsonObj.put("resp", "Username already taken!");
      }
  } else if (action.equals("ADDVEH")) {
      // Add vehicle
      String manuf = (String)jsonObject.get("manufacturer");
      String regis = (String)jsonObject.get("registration");
      String licen =((String)jsonObject.get("license"));
      if(addVehicle(manuf, regis, licen))
          jsonObj.put("resp", "Successfully added vehicle!");
      else {
          jsonObj.put("status", "fail");
          jsonObj.put("resp", "Vehicle alredy exists!");
      }
  }  And fifteeen more else ifs with different "actions"...
  </code></pre>
  
  <p>What I would like to do instead is something like this</p>
  
  <pre><code>if(action.equals("REGOPR")){
       awesomeMethod(registerOperator, 
                    "Custom succesffull message", 
                    "Fail message", 
                    "username", 
                    "password");
  } else if(action.equals("ADDVEH")) {
      awesomeMethod(addVehicle, 
                    "Custom succesfull message 2", 
                    "Fail message 2", 
                    "manufacturer", 
                    "registration", 
                    "license");
  }
  </code></pre>
  
  <p>So arbitrary number of Strings at the end and for each it should grab the value from json and just feed it into the given function.</p>