class CyclicReferenceTest { void test(Match match) { Match matcher = match.or(s -> Optional.empty(), i -> 2); Match matcher1 = match.or(s -> s.startsWith("_") ? Optional.of(1) : Optional.empty(), i -> 2); } } class Match { public Match or(Extractor e, Function c) { return this; } } interface Extractor { Optional unapply(T t); } interface Function { public V apply(W t); } class Optional { public static Optional empty() { return null; } public static Optional of(T value) { return null; } }