mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
allow more priority levels - up to 10
This commit is contained in:
parent
142c3beff6
commit
7d2881f4c1
4 changed files with 22 additions and 5 deletions
|
|
@ -212,15 +212,16 @@ public class Service extends AbstractJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set priority to service. Only 1 = high priority, 2 = medium and 3 = low are allowed.
|
* Set priority to service. Only 1 (very high) to 10 (very low) are allowed.
|
||||||
* <p>
|
* <p>
|
||||||
* Default is 2 = medium.
|
* Default is 2.
|
||||||
*
|
*
|
||||||
* @param priority
|
* @param priority
|
||||||
* @return builder
|
* @return builder
|
||||||
*/
|
*/
|
||||||
public Builder<T> setPriority(int priority) {
|
public Builder<T> setPriority(int priority) {
|
||||||
if(priority < 1 || priority > 3) throw new IllegalArgumentException("incorrect priority. only 1 = high, 2 = medium and 3 = low is allowed");
|
if (priority < 1 || priority > 10)
|
||||||
|
throw new IllegalArgumentException("incorrect priority. only priority values from 1 to 10 are allowed where 1 = high and 10 is low");
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ public class Shipment extends AbstractJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set priority to shipment. Only 1 = high priority, 2 = medium and 3 = low are allowed.
|
* Set priority to shipment. Only 1 (high) to 10 (low) are allowed.
|
||||||
* <p>
|
* <p>
|
||||||
* Default is 2 = medium.
|
* Default is 2 = medium.
|
||||||
*
|
*
|
||||||
|
|
@ -277,7 +277,8 @@ public class Shipment extends AbstractJob {
|
||||||
* @return builder
|
* @return builder
|
||||||
*/
|
*/
|
||||||
public Builder setPriority(int priority) {
|
public Builder setPriority(int priority) {
|
||||||
if(priority < 1 || priority > 3) throw new IllegalArgumentException("incorrect priority. only 1 = high, 2 = medium and 3 = low is allowed");
|
if (priority < 1 || priority > 10)
|
||||||
|
throw new IllegalArgumentException("incorrect priority. only 1 (very high) to 10 (very low) are allowed");
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -250,6 +250,13 @@ public class ServiceTest {
|
||||||
Assert.assertEquals(3, s.getPriority());
|
Assert.assertEquals(3, s.getPriority());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSettingPriorities_itShouldBeSetCorrectly3() {
|
||||||
|
Service s = Service.Builder.newInstance("s").setLocation(Location.newInstance("loc"))
|
||||||
|
.setPriority(10).build();
|
||||||
|
Assert.assertEquals(10, s.getPriority());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenNotSettingPriorities_defaultShouldBe2(){
|
public void whenNotSettingPriorities_defaultShouldBe2(){
|
||||||
Service s = Service.Builder.newInstance("s").setLocation(Location.newInstance("loc"))
|
Service s = Service.Builder.newInstance("s").setLocation(Location.newInstance("loc"))
|
||||||
|
|
|
||||||
|
|
@ -401,6 +401,14 @@ public class ShipmentTest {
|
||||||
Assert.assertEquals(3, s.getPriority());
|
Assert.assertEquals(3, s.getPriority());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSettingPriorities_itShouldBeSetCorrectly3() {
|
||||||
|
Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.newInstance("loc"))
|
||||||
|
.setDeliveryLocation(Location.newInstance("loc"))
|
||||||
|
.setPriority(10).build();
|
||||||
|
Assert.assertEquals(10, s.getPriority());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenNotSettingPriorities_defaultShouldBe2(){
|
public void whenNotSettingPriorities_defaultShouldBe2(){
|
||||||
Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.newInstance("loc"))
|
Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.newInstance("loc"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue