17
17
*/
18
18
package com .graphhopper .jsprit .core .problem .job ;
19
19
20
+ import java .util .Collection ;
21
+
20
22
import com .graphhopper .jsprit .core .problem .AbstractJob ;
21
23
import com .graphhopper .jsprit .core .problem .Capacity ;
22
24
import com .graphhopper .jsprit .core .problem .Location ;
26
28
import com .graphhopper .jsprit .core .problem .solution .route .activity .TimeWindowsImpl ;
27
29
import com .graphhopper .jsprit .core .util .Coordinate ;
28
30
29
- import java .util .Collection ;
30
-
31
31
/**
32
32
* Service implementation of a job.
33
33
* <p>
@@ -86,15 +86,16 @@ public static Builder newInstance(String id) {
86
86
87
87
protected TimeWindowsImpl timeWindows ;
88
88
89
- private boolean twAdded = false ;
89
+ private boolean twAdded = false ;
90
90
91
91
private int priority = 2 ;
92
+ protected Object userData ;
92
93
93
- Builder (String id ){
94
- this .id = id ;
95
- timeWindows = new TimeWindowsImpl ();
96
- timeWindows .add (timeWindow );
97
- }
94
+ Builder (String id ){
95
+ this .id = id ;
96
+ timeWindows = new TimeWindowsImpl ();
97
+ timeWindows .add (timeWindow );
98
+ }
98
99
99
100
/**
100
101
* Protected method to set the type-name of the service.
@@ -137,6 +138,24 @@ public Builder<T> setServiceTime(double serviceTime) {
137
138
return this ;
138
139
}
139
140
141
+ /**
142
+ * Sets user specific domain data associated with the object.
143
+ *
144
+ * <p>
145
+ * The user data is a black box for the framework, it only stores it,
146
+ * but never interacts with it in any way.
147
+ * </p>
148
+ *
149
+ * @param userData
150
+ * any object holding the domain specific user data
151
+ * associated with the object.
152
+ * @return builder
153
+ */
154
+ public Builder <T > setUserData (Object userData ) {
155
+ this .userData = userData ;
156
+ return this ;
157
+ }
158
+
140
159
/**
141
160
* Adds capacity dimension.
142
161
*
@@ -247,7 +266,8 @@ public Builder<T> setPriority(int priority) {
247
266
248
267
private final int priority ;
249
268
250
- Service (Builder builder ) {
269
+ Service (Builder <?> builder ) {
270
+ setUserData (builder .userData );
251
271
id = builder .id ;
252
272
serviceTime = builder .serviceTime ;
253
273
timeWindow = builder .timeWindow ;
@@ -256,13 +276,13 @@ public Builder<T> setPriority(int priority) {
256
276
skills = builder .skills ;
257
277
name = builder .name ;
258
278
location = builder .location ;
259
- timeWindowManager = builder .timeWindows ;
279
+ timeWindowManager = builder .timeWindows ;
260
280
priority = builder .priority ;
261
- }
281
+ }
262
282
263
- public Collection <TimeWindow > getTimeWindows (){
264
- return timeWindowManager .getTimeWindows ();
265
- }
283
+ public Collection <TimeWindow > getTimeWindows (){
284
+ return timeWindowManager .getTimeWindows ();
285
+ }
266
286
267
287
@ Override
268
288
public String getId () {
@@ -367,6 +387,7 @@ public String getName() {
367
387
*
368
388
* @return priority
369
389
*/
390
+ @ Override
370
391
public int getPriority () {
371
392
return priority ;
372
393
}
0 commit comments