void (Base base) { if (base.sub == 1) doSomething((Sub1) base, (s, b) -> { System.out.println(s); this.s1 = b; }); if (base.sub == 2) doSomething((Sub2) base, (s, b) -> { System.out.println(s); this.s2 = b; }); }