List<AbstractMessage> (boolean includeReadMessages, boolean includeSubmittedMessages) { List<AbstractMessage> result = new ArrayList<>(); for (AbstractMessage message : myErrors) { if ((!message.isRead() && !message.isSubmitted()) || (message.isRead() && includeReadMessages) || (message.isSubmitted() && includeSubmittedMessages)) { result.add(message); } } return result; }