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);
  }
 @SuppressWarnings("unchecked")
 private void renameRoute(
     BaseRoute route,
     BaseRoute routeToWrite,
     int startIndex,
     int endIndex,
     int trackIndex,
     OutputStream... targets) {
   // gives splitted TomTomRoute and SimpleRoute routes a more useful name for the fragment
   if (route.getFormat() instanceof TomTomRouteFormat
       || route.getFormat() instanceof SimpleFormat
       || route.getFormat() instanceof GpxFormat
           && routeToWrite.getFormat() instanceof BcrFormat) {
     String name = createRouteName(routeToWrite.getPositions().subList(startIndex, endIndex));
     if (targets.length > 1) name = "Track" + (trackIndex + 1) + ": " + name;
     routeToWrite.setName(name);
   }
 }