void (Object anItem) { if (anItem instanceof MyWeightItem) { mySelectedItem = (MyWeightItem)anItem; } else if (anItem instanceof String) { mySelectedItem = ContainerUtil.find(myItems, item -> item.subFamily.equals(anItem)); } }