4
4
import uk .ac .ox .oxfish .regulations .conditions .*;
5
5
import uk .ac .ox .oxfish .utility .AlgorithmFactory ;
6
6
import uk .ac .ox .oxfish .utility .parameters .IntegerParameter ;
7
+ import uk .ac .ox .oxfish .utility .parameters .StringParameter ;
7
8
import uk .ac .ox .poseidon .regulations .api .Regulations ;
8
9
9
10
import java .time .MonthDay ;
12
13
import static uk .ac .ox .oxfish .regulations .conditions .False .FALSE ;
13
14
14
15
public class Closure implements RegulationFactory {
16
+ private StringParameter agentTag ;
15
17
private IntegerParameter beginningDay ;
16
18
private IntegerParameter beginningMonth ;
17
19
private IntegerParameter endDay ;
18
20
private IntegerParameter endMonth ;
19
21
private IntegerParameter daysToForbidDeploymentsBefore ;
20
22
23
+ @ SuppressWarnings ("unused" )
21
24
public Closure () {
22
25
}
23
26
27
+ @ SuppressWarnings ({"WeakerAccess" , "unused" })
24
28
public Closure (
29
+ final String agentTag ,
25
30
final MonthDay beginning ,
26
31
final MonthDay end ,
27
32
final int daysToForbidDeploymentsBefore
28
33
) {
29
34
this (
35
+ new StringParameter (agentTag ),
30
36
new IntegerParameter (beginning .getDayOfMonth ()),
31
37
new IntegerParameter (beginning .getMonthValue ()),
32
38
new IntegerParameter (end .getDayOfMonth ()),
@@ -35,20 +41,32 @@ public Closure(
35
41
);
36
42
}
37
43
44
+ @ SuppressWarnings ("WeakerAccess" )
38
45
public Closure (
46
+ final StringParameter agentTag ,
39
47
final IntegerParameter beginningDay ,
40
48
final IntegerParameter beginningMonth ,
41
49
final IntegerParameter endDay ,
42
50
final IntegerParameter endMonth ,
43
51
final IntegerParameter daysToForbidDeploymentsBefore
44
52
) {
53
+ this .agentTag = agentTag ;
45
54
this .beginningDay = beginningDay ;
46
55
this .beginningMonth = beginningMonth ;
47
56
this .endDay = endDay ;
48
57
this .endMonth = endMonth ;
49
58
this .daysToForbidDeploymentsBefore = daysToForbidDeploymentsBefore ;
50
59
}
51
60
61
+ public StringParameter getAgentTag () {
62
+ return agentTag ;
63
+ }
64
+
65
+ @ SuppressWarnings ("unused" )
66
+ public void setAgentTag (final StringParameter agentTag ) {
67
+ this .agentTag = agentTag ;
68
+ }
69
+
52
70
@ SuppressWarnings ("unused" )
53
71
public IntegerParameter getDaysToForbidDeploymentsBefore () {
54
72
return daysToForbidDeploymentsBefore ;
@@ -103,16 +121,13 @@ public void setEndMonth(final IntegerParameter endMonth) {
103
121
public AlgorithmFactory <Regulations > get () {
104
122
final MonthDay beginning = getBeginning ();
105
123
return new ForbiddenIf (
106
- new AnyOf (
107
- daysToForbidDeploymentsBefore .getIntValue () >= 1
108
- ? forbidDeploymentsBefore (beginning , daysToForbidDeploymentsBefore .getIntValue ())
109
- : FALSE ,
110
- new AllOf (
111
- new AgentHasTag ("closure A" ),
112
- new BetweenYearlyDates (
113
- beginning ,
114
- getEnd ()
115
- )
124
+ new AllOf (
125
+ new AgentHasTag (agentTag .getValue ()),
126
+ new AnyOf (
127
+ daysToForbidDeploymentsBefore .getIntValue () >= 1
128
+ ? forbidDeploymentsBefore (beginning , daysToForbidDeploymentsBefore .getIntValue ())
129
+ : FALSE ,
130
+ new BetweenYearlyDates (beginning , getEnd ())
116
131
)
117
132
)
118
133
);
@@ -122,9 +137,8 @@ public MonthDay getBeginning() {
122
137
return makeMonthDay (beginningMonth , beginningDay );
123
138
}
124
139
125
- private AllOf forbidDeploymentsBefore (final MonthDay beginning , final int numDays ) {
140
+ static AllOf forbidDeploymentsBefore (final MonthDay beginning , final int numDays ) {
126
141
return new AllOf (
127
- new AgentHasTag ("closure A" ),
128
142
new ActionCodeIs ("DPL" ),
129
143
new BetweenYearlyDates (
130
144
addDays (beginning , -numDays ),
0 commit comments