mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
added .getSkills() to jobs
This commit is contained in:
parent
22265c16d8
commit
e99392572d
3 changed files with 25 additions and 27 deletions
|
|
@ -18,6 +18,7 @@ package jsprit.core.problem.job;
|
||||||
|
|
||||||
|
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Skills;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic interface for all jobs.
|
* Basic interface for all jobs.
|
||||||
|
|
@ -40,5 +41,12 @@ public interface Job {
|
||||||
* @return Capacity
|
* @return Capacity
|
||||||
*/
|
*/
|
||||||
public Capacity getSize();
|
public Capacity getSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns required skills.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Skills getRequiredSkills();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Skills;
|
||||||
import jsprit.core.problem.solution.route.activity.TimeWindow;
|
import jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||||
import jsprit.core.util.Coordinate;
|
import jsprit.core.util.Coordinate;
|
||||||
|
|
||||||
|
|
@ -71,7 +72,7 @@ public class Service implements Job {
|
||||||
|
|
||||||
protected Capacity capacity;
|
protected Capacity capacity;
|
||||||
|
|
||||||
protected Set<String> skills = new HashSet<String>();
|
protected Skills.Builder skillBuilder = Skills.Builder.newInstance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the builder.
|
* Constructs the builder.
|
||||||
|
|
@ -187,7 +188,7 @@ public class Service implements Job {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addSkill(String string) {
|
public Builder addSkill(String string) {
|
||||||
skills.add(string.toLowerCase());
|
skillBuilder.addSkill(string);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,7 +209,7 @@ public class Service implements Job {
|
||||||
|
|
||||||
private final Capacity size;
|
private final Capacity size;
|
||||||
|
|
||||||
private final Set<String> skills;
|
private final Skills skills;
|
||||||
|
|
||||||
Service(Builder builder){
|
Service(Builder builder){
|
||||||
id = builder.id;
|
id = builder.id;
|
||||||
|
|
@ -218,7 +219,7 @@ public class Service implements Job {
|
||||||
timeWindow = builder.timeWindow;
|
timeWindow = builder.timeWindow;
|
||||||
type = builder.type;
|
type = builder.type;
|
||||||
size = builder.capacity;
|
size = builder.capacity;
|
||||||
skills = builder.skills;
|
skills = builder.skillBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -319,18 +320,9 @@ public class Service implements Job {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<String> getRequiredSkills() {
|
public Skills getRequiredSkills() {
|
||||||
return Collections.unmodifiableSet(skills);
|
return skills;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this contains requiredSkill. Not case sensitive.
|
|
||||||
*
|
|
||||||
* @param requiredSkill
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean requiresSkill(String requiredSkill){
|
|
||||||
return skills.contains(requiredSkill.toLowerCase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Skills;
|
||||||
import jsprit.core.problem.solution.route.activity.TimeWindow;
|
import jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||||
import jsprit.core.util.Coordinate;
|
import jsprit.core.util.Coordinate;
|
||||||
|
|
||||||
|
|
@ -57,7 +58,7 @@ public class Shipment implements Job{
|
||||||
|
|
||||||
private Capacity capacity;
|
private Capacity capacity;
|
||||||
|
|
||||||
private Set<String> skills = new HashSet<String>();
|
private Skills.Builder skillBuilder = Skills.Builder.newInstance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns new instance of this builder.
|
* Returns new instance of this builder.
|
||||||
|
|
@ -236,8 +237,8 @@ public class Shipment implements Job{
|
||||||
return new Shipment(this);
|
return new Shipment(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addSkill(String string) {
|
public Builder addSkill(String skill) {
|
||||||
skills.add(string.toLowerCase());
|
skillBuilder.addSkill(skill);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -264,7 +265,7 @@ public class Shipment implements Job{
|
||||||
|
|
||||||
private final Capacity capacity;
|
private final Capacity capacity;
|
||||||
|
|
||||||
private final Set<String> skills;
|
private final Skills skills;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -283,7 +284,7 @@ public class Shipment implements Job{
|
||||||
this.deliveryServiceTime = builder.deliveryServiceTime;
|
this.deliveryServiceTime = builder.deliveryServiceTime;
|
||||||
this.deliveryTimeWindow = builder.deliveryTimeWindow;
|
this.deliveryTimeWindow = builder.deliveryTimeWindow;
|
||||||
this.capacity = builder.capacity;
|
this.capacity = builder.capacity;
|
||||||
this.skills = builder.skills;
|
this.skills = builder.skillBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -400,11 +401,8 @@ public class Shipment implements Job{
|
||||||
return capacity;
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getRequiredSkills() {
|
public Skills getRequiredSkills() {
|
||||||
return Collections.unmodifiableSet(skills);
|
return skills;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean requiresSkill(String requiredSkill){
|
|
||||||
return skills.contains(requiredSkill.toLowerCase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue