ModalityStateEx (@NotNull Object anEntity) { List<@NotNull Object> modalEntities = getModalEntities(); List<Object> list = new ArrayList<>(modalEntities.size() + 1); list.addAll(modalEntities); list.add(anEntity); return new ModalityStateEx(list); }