1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

add javadocs and tests

This commit is contained in:
oblonski 2014-01-16 17:07:38 -05:00
parent ca0caf450c
commit 6b4656afff
4 changed files with 87 additions and 3 deletions

View file

@ -16,19 +16,42 @@
******************************************************************************/
package jsprit.core.problem.job;
/**
* Delivery extends Service and is intended to model a Service where smth is UNLOADED (i.e. delivered) from a transport unit.
*
* @author schroeder
*
*/
public class Delivery extends Service{
public static class Builder extends Service.Builder {
/**
* Returns a new instance of Delivery.Builder
*
* @param id
* @param size
* @return builder
*/
public static Builder newInstance(String id, int size){
return new Builder(id,size);
}
/**
* Constructs the builder
*
* @param id
* @param size
*/
Builder(String id, int size) {
super(id, size);
}
/**
* Builds Delivery.
*
* @return delivery
* @throw {@link IllegalStateException} if neither locationId nor coord is set
*/
public Delivery build(){
if(locationId == null) {
if(coord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not.");
@ -40,6 +63,11 @@ public class Delivery extends Service{
}
/**
* Constructs Delivery.
*
* @param builder
*/
Delivery(Builder builder) {
super(builder);

View file

@ -16,18 +16,45 @@
******************************************************************************/
package jsprit.core.problem.job;
/**
* Pickup extends Service and is intended to model a Service where smth is LOADED (i.e. picked up) to a transport unit.
*
* @author schroeder
*
*/
public class Pickup extends Service {
public static class Builder extends Service.Builder {
/**
* Returns a new instance of Pickup.Builder
*
* @param id
* @param size
* @return builder
*/
public static Builder newInstance(String id, int size){
return new Builder(id,size);
}
/**
* Constructs the builder.
*
* @param id
* @param size
*/
Builder(String id, int size) {
super(id, size);
}
/**
* Builds Pickup.
*
*<p>Pickup type is "pickup"
*
* @return pickup
* @throw {@link IllegalStateException} if neither locationId nor coordinate has been set
*/
public Pickup build(){
if(locationId == null) {
if(coord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not.");
@ -39,6 +66,11 @@ public class Pickup extends Service {
}
/**
* Constructs the Pickup
*
* @param builder
*/
Pickup(Builder builder) {
super(builder);
}

View file

@ -0,0 +1,12 @@
package jsprit.core.problem.job;
import org.junit.Test;
public class DeliveryTest {
@Test(expected=IllegalStateException.class)
public void whenNeitherLocationIdNorCoordIsSet_itThrowsException(){
Delivery.Builder.newInstance("p", 0).build();
}
}

View file

@ -0,0 +1,12 @@
package jsprit.core.problem.job;
import org.junit.Test;
public class PickupTest {
@Test(expected=IllegalStateException.class)
public void whenNeitherLocationIdNorCoordIsSet_itThrowsException(){
Pickup.Builder.newInstance("p", 0).build();
}
}