15
15
public class MaxStopCountLimit {
16
16
17
17
private static final int DEFAULT_LIMIT = 500 ;
18
- private static final Map <StreetMode , Integer > DEFAULT_FOR_MODE = Map .of ();
18
+ private static final Map <StreetMode , Integer > DEFAULT_FOR_MODES = Map .of ();
19
19
20
20
public static final MaxStopCountLimit DEFAULT = new MaxStopCountLimit ();
21
21
22
22
private final int defaultLimit ;
23
- private final Map <StreetMode , Integer > limitForMode ;
23
+ private final Map <StreetMode , Integer > limitsForModes ;
24
24
25
25
public MaxStopCountLimit () {
26
26
this .defaultLimit = DEFAULT_LIMIT ;
27
- this .limitForMode = DEFAULT_FOR_MODE ;
27
+ this .limitsForModes = DEFAULT_FOR_MODES ;
28
28
}
29
29
30
30
MaxStopCountLimit (Builder builder ) {
31
31
this .defaultLimit = IntUtils .requireNotNegative (builder .defaultLimit ());
32
- this .limitForMode = builder .copyCustomLimits ();
32
+ this .limitsForModes = builder .copyCustomLimits ();
33
33
}
34
34
35
35
public static Builder of () {
@@ -44,7 +44,7 @@ public Builder copyOf() {
44
44
* Get the max stop count limit for mode. If no custom value is defined, default is used.
45
45
*/
46
46
public int limitForMode (StreetMode mode ) {
47
- return limitForMode .getOrDefault (mode , defaultLimit );
47
+ return limitsForModes .getOrDefault (mode , defaultLimit );
48
48
}
49
49
50
50
public int defaultLimit () {
@@ -56,7 +56,7 @@ public String toString() {
56
56
return ToStringBuilder
57
57
.of (MaxStopCountLimit .class )
58
58
.addNum ("defaultLimit" , defaultLimit , DEFAULT_LIMIT )
59
- .addObj ("limitForMode " , limitForMode , DEFAULT_FOR_MODE )
59
+ .addObj ("limitsForModes " , limitsForModes , DEFAULT_FOR_MODES )
60
60
.toString ();
61
61
}
62
62
@@ -67,27 +67,27 @@ public boolean equals(Object o) {
67
67
68
68
var that = (MaxStopCountLimit ) o ;
69
69
70
- return (defaultLimit == that .defaultLimit && limitForMode .equals (that .limitForMode ));
70
+ return (defaultLimit == that .defaultLimit && limitsForModes .equals (that .limitsForModes ));
71
71
}
72
72
73
73
@ Override
74
74
public int hashCode () {
75
- return Objects .hash (defaultLimit , limitForMode );
75
+ return Objects .hash (defaultLimit , limitsForModes );
76
76
}
77
77
78
- private Map <StreetMode , Integer > limitForMode () {
79
- return limitForMode ;
78
+ private Map <StreetMode , Integer > limitsForModes () {
79
+ return limitsForModes ;
80
80
}
81
81
82
82
private boolean hasCustomLimit (StreetMode mode ) {
83
- return limitForMode .containsKey (mode );
83
+ return limitsForModes .containsKey (mode );
84
84
}
85
85
86
86
public static class Builder {
87
87
88
88
private final MaxStopCountLimit original ;
89
89
private int defaultLimit ;
90
- private Map <StreetMode , Integer > limitForMode = null ;
90
+ private Map <StreetMode , Integer > limitsForModes = null ;
91
91
92
92
Builder (MaxStopCountLimit original ) {
93
93
this .original = original ;
@@ -105,15 +105,15 @@ public Builder withDefaultLimit(int defaultLimit) {
105
105
106
106
public Builder with (StreetMode mode , Integer limit ) {
107
107
// Lazy initialize the valueForEnum map
108
- if (limitForMode == null ) {
109
- limitForMode = new EnumMap <>(StreetMode .class );
108
+ if (limitsForModes == null ) {
109
+ limitsForModes = new EnumMap <>(StreetMode .class );
110
110
for (StreetMode it : StreetMode .values ()) {
111
111
if (original .hasCustomLimit (it )) {
112
- limitForMode .put (it , original .limitForMode (it ));
112
+ limitsForModes .put (it , original .limitForMode (it ));
113
113
}
114
114
}
115
115
}
116
- limitForMode .put (mode , limit );
116
+ limitsForModes .put (mode , limit );
117
117
return this ;
118
118
}
119
119
@@ -130,13 +130,13 @@ public Builder withLimitsForModes(Map<StreetMode, Integer> limitsForModes) {
130
130
* can be used to generate new values if desired.
131
131
* */
132
132
Map <StreetMode , Integer > copyCustomLimits () {
133
- if (limitForMode == null ) {
133
+ if (limitsForModes == null ) {
134
134
// The limitForMode is protected and should never be mutated, so we can reuse it
135
- return original .limitForMode ();
135
+ return original .limitsForModes ();
136
136
}
137
137
138
138
var copy = new EnumMap <StreetMode , Integer >(StreetMode .class );
139
- for (Map .Entry <StreetMode , Integer > it : limitForMode .entrySet ()) {
139
+ for (Map .Entry <StreetMode , Integer > it : limitsForModes .entrySet ()) {
140
140
if (defaultLimit != it .getValue ()) {
141
141
copy .put (it .getKey (), it .getValue ());
142
142
}
0 commit comments