class Foo { boolean foo(Object o, final PairFunction fun){ boolean result = true; result |= fun.fun(path); if (o instanceof String) { ((String) o).substring() } } void foo(String s) {} } interface PairFunction { U fun(T t, V v); }