I have a list of Triples, e.g.
import org.apache.commons.lang3.tuple.ImmutableTriple;
final HashMap<String, ImmutableTriple<String, String, Function<String, String>>> olMap = new HashMap();
and I want to add something like
olMap.put("start", new ImmutableTriple("str1", "str2", MyClass::minusOne));
I get the following error:
The constructor ImmutableTriple(String, String, MyClass::minusOne) is undefined
which is
private static String minusOne(String count) {
String ret = count;
if (count != null) {
try {
ret = (Integer.parseInt(count) - 1) + "";
} catch (final Exception e) {
// nothing to do cuz input wasn't a number...
}
}
return ret;
}
but somehow I do not get the signatures properly. And last but not least how to call finally the method? i.e. is this the correct syntax?
ol.get("start").right.apply("100")
UPDATE:
I've found the correct syntax:
final HashMap<String, Triple<String, String, Function<String, String>>> olMap = new HashMap();
olMap.put("start", new Triple.of("str1", "str2", MyClass::minusOne));
Thx for the help and reassurance - otherwise I wouldn't have found it