abstract class A {}
class B extends A {}
class C extends A {}
List<A> items = // objects of B,C types
items.stream.map(item -> build(item));
How to keep different logic in build method for type B and C. I've tried to declare build(B b) and build(C c) as I thought it checks the actual type in the runtime but it looks it checks declared type. I can use instanceof but think there should be a better way. B,C are entity beans thus cannot add my logic there