package org.opentripplanner.profile;

import java.io.Serializable;

import org.joda.time.LocalDate;
import org.opentripplanner.api.param.LatLon;
import org.opentripplanner.routing.core.TraverseModeSet;

import javax.ws.rs.DefaultValue;
import javax.ws.rs.QueryParam;

/**
 * All the modifiable parameters for profile routing.
 */
public class ProfileRequest implements Serializable {

    public double fromLat;
    public double fromLon;
    public double toLat;
    public double toLon;
    
    public int    fromTime;
    public int    toTime;

    /* Speeds are in meters per second. */
    public float  walkSpeed;
    public float  bikeSpeed;
    public float  carSpeed;

    /* The following times are all in minutes. */
    public int    streetTime;
    public int    maxWalkTime;
    public int    maxBikeTime;
    public int    maxCarTime;
    public int    minBikeTime;
    public int    minCarTime;

    public LocalDate date;
    public Option.SortOrder orderBy;
    public int limit; // the maximum number of options presented PER ACCESS MODE
    public TraverseModeSet accessModes, egressModes, directModes, transitModes;
    public boolean analyst = false; // if true, propagate travel times out to street network

    /*
      This parameter compensates for the fact that GTFS does not contain information about schedule deviation (lateness).
      The min-max travel time range for some trains is zero, since the trips are reported to always have the same
      timings in the schedule. Such an option does not overlap (temporally) its alternatives, and is too easily
      eliminated by an alternative that is only marginally better. We want to effectively push the max travel time of
      alternatives out a bit to account for the fact that they don't always run on schedule.
    */
    public int suboptimalMinutes;
    
    public ProfileRequest clone () {
        ProfileRequest ret = new ProfileRequest();
        ret.fromLat = fromLat;
        ret.fromLon = fromLon;
        ret.toLat = toLat;
        ret.toLon = toLon;
        ret.fromTime = fromTime;
        ret.toTime = toTime;
        
        ret.walkSpeed = walkSpeed;
        ret.bikeSpeed = bikeSpeed;
        ret.carSpeed = carSpeed;
        
        ret.streetTime = streetTime;
        ret.maxWalkTime = maxWalkTime;
        ret.maxBikeTime = maxBikeTime;
        ret.maxCarTime = maxCarTime;
        ret.minBikeTime = minBikeTime;
        ret.minCarTime = minCarTime;
        
        // LocalDate is immutable, no need to copy
        ret.date = date;
        // TODO: deep clone needed? mutable?
        ret.orderBy = orderBy;
        ret.limit = limit;
        ret.accessModes = accessModes != null ? accessModes.clone() : null;
        ret.egressModes = egressModes != null ? egressModes.clone() : null;
        ret.directModes = directModes != null ? directModes.clone() : null;
        ret.transitModes = transitModes != null ? transitModes.clone() : null;
        
        ret.analyst = analyst;
        ret.suboptimalMinutes = suboptimalMinutes;
        
        return ret;
    }
}

@@ -35,38 +35,8 @@
 e;%0A%0A
-import java.io.Serializable;%0A%0A
 impo
@@ -103,108 +103,40 @@
 aram
-.LatLon;%0Aimport org.opentripplanner.routing.core.TraverseModeSet;%0A%0Aimport javax.ws.rs.DefaultValu
+eter.QualifiedModeSetSequenc
 e;%0A
+%0A
 impo
@@ -146,26 +146,24 @@
 java
-x.ws.rs.QueryParam
+.io.Serializable
 ;%0A%0A/
@@ -274,16 +274,27 @@
 alizable
+, Cloneable
  %7B%0A%0A    
@@ -977,23 +977,32 @@
 lic 
-TraverseModeSet
+QualifiedModeSetSequence
  acc
@@ -1756,1247 +1756,7 @@
 es;%0A
-    %0A    public ProfileRequest clone () %7B%0A        ProfileRequest ret = new ProfileRequest();%0A        ret.fromLat = fromLat;%0A        ret.fromLon = fromLon;%0A        ret.toLat = toLat;%0A        ret.toLon = toLon;%0A        ret.fromTime = fromTime;%0A        ret.toTime = toTime;%0A        %0A        ret.walkSpeed = walkSpeed;%0A        ret.bikeSpeed = bikeSpeed;%0A        ret.carSpeed = carSpeed;%0A        %0A        ret.streetTime = streetTime;%0A        ret.maxWalkTime = maxWalkTime;%0A        ret.maxBikeTime = maxBikeTime;%0A        ret.maxCarTime = maxCarTime;%0A        ret.minBikeTime = minBikeTime;%0A        ret.minCarTime = minCarTime;%0A        %0A        // LocalDate is immutable, no need to copy%0A        ret.date = date;%0A        // TODO: deep clone needed? mutable?%0A        ret.orderBy = orderBy;%0A        ret.limit = limit;%0A        ret.accessModes = accessModes != null ? accessModes.clone() : null;%0A        ret.egressModes = egressModes != null ? egressModes.clone() : null;%0A        ret.directModes = directModes != null ? directModes.clone() : null;%0A        ret.transitModes = transitModes != null ? transitModes.clone() : null;%0A        %0A        ret.analyst = analyst;%0A        ret.suboptimalMinutes = suboptimalMinutes;%0A        %0A        return ret;%0A    %7D
 %0A%7D%0A

remove deep copy method on ProfileRequest and make it cloneable