20
20
21
21
package com .cognifide .apm .main .permissions ;
22
22
23
- import com .google .common .collect .ImmutableList ;
24
- import com .google .common .collect .ImmutableMap ;
25
23
import com .google .common .collect .ImmutableSet ;
26
24
import java .util .Collections ;
27
25
import java .util .HashMap ;
28
26
import java .util .List ;
29
27
import java .util .Map ;
28
+ import java .util .Optional ;
30
29
import java .util .Set ;
31
30
import javax .jcr .PropertyType ;
32
31
import javax .jcr .Value ;
33
32
import javax .jcr .ValueFactory ;
34
33
import javax .jcr .ValueFormatException ;
35
- import org .apache .commons .collections4 .CollectionUtils ;
36
34
import org .apache .commons .lang3 .StringUtils ;
37
35
38
36
public class Restrictions {
@@ -62,17 +60,10 @@ public class Restrictions {
62
60
63
61
public Restrictions (String glob , List <String > ntNames , List <String > itemNames , Map <String , Object > customRestrictions ) {
64
62
this .glob = glob ;
65
- this .ntNames = notNullCopy (ntNames );
66
- this .itemNames = notNullCopy (itemNames );
67
- this .customRestrictions = notNullCopy (customRestrictions );
68
- }
69
-
70
- private List <String > notNullCopy (List <String > strings ) {
71
- return strings != null ? ImmutableList .copyOf (strings ) : Collections .emptyList ();
72
- }
73
-
74
- private Map <String , Object > notNullCopy (Map <String , Object > items ) {
75
- return items != null ? ImmutableMap .copyOf (items ) : Collections .emptyMap ();
63
+ this .ntNames = ntNames ;
64
+ this .itemNames = itemNames ;
65
+ this .customRestrictions = Optional .ofNullable (customRestrictions )
66
+ .orElse (Collections .emptyMap ());
76
67
}
77
68
78
69
public Map <String , Value > getSingleValueRestrictions (ValueFactory valueFactory ) throws ValueFormatException {
@@ -93,7 +84,7 @@ public Map<String, Value> getSingleValueRestrictions(ValueFactory valueFactory)
93
84
}
94
85
95
86
private void addRestriction (ValueFactory valueFactory , Map <String , Value > result , String key , String value ) throws ValueFormatException {
96
- if (StringUtils . isNotBlank ( value ) ) {
87
+ if (value != null ) {
97
88
result .put (key , createValue (valueFactory , key , value ));
98
89
}
99
90
}
@@ -132,7 +123,7 @@ public Map<String, Value[]> getMultiValueRestrictions(ValueFactory valueFactory)
132
123
}
133
124
134
125
private void addRestrictions (ValueFactory valueFactory , Map <String , Value []> result , String key , List <String > names ) throws ValueFormatException {
135
- if (! CollectionUtils . isEmpty ( names ) ) {
126
+ if (names != null ) {
136
127
result .put (key , createRestrictions (valueFactory , key , names ));
137
128
}
138
129
}
0 commit comments