/** * Initialize the list of {@link VTNFlowMatch} instances. * * @param srcList A list of objects used to create a list of * {@link VTNFlowMatch} instances. * @return A list of {@link VTNFlowMatch} instance. * @throws RpcException An error occurred. */ protected final List<VTNFlowMatch> initialize(List<T> srcList) throws RpcException { if (srcList == null || srcList.isEmpty()) { return Collections.<VTNFlowMatch>emptyList(); } // Ensure that all match indices are unique. List<VTNFlowMatch> list = newList(srcList); Set<Integer> indices = new HashSet<>(); for (T obj: srcList) { VTNFlowMatch vfmatch = convert(obj); Integer index = vfmatch.getIdentifier(); FlowCondUtils.verifyMatchIndex(indices, index); add(list, vfmatch); } // Sort matches by index. VTNIdentifiableComparator<Integer> comparator = new VTNIdentifiableComparator<>(Integer.class); Collections.sort(list, comparator); return list; }