mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add factory methods to Location to simplify location building
This commit is contained in:
parent
657f85e896
commit
f8f063773a
3 changed files with 101 additions and 13 deletions
|
|
@ -24,6 +24,37 @@ import jsprit.core.util.Coordinate;
|
|||
*/
|
||||
public final class Location implements HasIndex, HasId{
|
||||
|
||||
/**
|
||||
* Factory method (and shortcut) for creating a location object just with x and y coordinates.
|
||||
*
|
||||
* @param x coordinate
|
||||
* @param y coordinate
|
||||
* @return location
|
||||
*/
|
||||
public static Location newInstance(double x, double y){
|
||||
return Location.Builder.newInstance().setCoordinate(Coordinate.newInstance(x,y)).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method (and shortcut) for creating location object just with id
|
||||
*
|
||||
* @param id location id
|
||||
* @return location
|
||||
*/
|
||||
public static Location newInstance(String id){
|
||||
return Location.Builder.newInstance().setId(id).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method (and shortcut) for creating location object just with location index
|
||||
*
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
public static Location newInstance(int index){
|
||||
return Location.Builder.newInstance().setIndex(index).build();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue