@Override public void transmitOperationList(final List<VdcOperation<?, ?>> operations) { // Operations can be either actions or queries. Both require different handling so lets // Split them out into two lists so we can process them independently. List<VdcOperation<?, ?>> queriesList = new ArrayList<>(); Map<ActionType, List<VdcOperation<?, ?>>> actionsMap = new HashMap<>(); for (VdcOperation<?, ?> operation: operations) { if (operation.isAction()) { List<VdcOperation<?, ?>> actionsList = actionsMap.get(operation.getOperation()); if (actionsList == null) { actionsList = new ArrayList<>(); actionsMap.put((ActionType) operation.getOperation(), actionsList); } actionsList.add(operation); } else { queriesList.add(operation); } } if (!actionsMap.isEmpty()) { // We have some actions, call method to send actions. transmitMultipleActions(actionsMap); } if (!queriesList.isEmpty()) { // We have some queries, call method to send queries. transmitMultipleQueries(queriesList); } }