public void sort(Comparator<P> comparator) { List<P> positions = getPositions(); @SuppressWarnings({"SuspiciousToArrayCall", "unchecked"}) P[] sorted = (P[]) positions.toArray(new BaseNavigationPosition[positions.size()]); Arrays.sort(sorted, comparator); //noinspection unchecked order(asList(sorted)); }
public void revert() { List<P> positions = getPositions(); List<P> reverted = new ArrayList<>(); for (P position : positions) { reverted.add(0, position); } order(reverted); String routeName = getName(); if (!routeName.endsWith(REVERSE_ROUTE_NAME_POSTFIX)) routeName = routeName + REVERSE_ROUTE_NAME_POSTFIX; else routeName = routeName.substring(0, routeName.length() - REVERSE_ROUTE_NAME_POSTFIX.length()); setName(routeName); }