Skip to content

Commit 0c7c9f4

Browse files
committed
refactor
1 parent 53a1ca8 commit 0c7c9f4

File tree

1 file changed

+7
-16
lines changed
  • app/aem/actions.main/src/main/java/com/cognifide/apm/main/permissions

1 file changed

+7
-16
lines changed

app/aem/actions.main/src/main/java/com/cognifide/apm/main/permissions/Restrictions.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@
2020

2121
package com.cognifide.apm.main.permissions;
2222

23-
import com.google.common.collect.ImmutableList;
24-
import com.google.common.collect.ImmutableMap;
2523
import com.google.common.collect.ImmutableSet;
2624
import java.util.Collections;
2725
import java.util.HashMap;
2826
import java.util.List;
2927
import java.util.Map;
28+
import java.util.Optional;
3029
import java.util.Set;
3130
import javax.jcr.PropertyType;
3231
import javax.jcr.Value;
3332
import javax.jcr.ValueFactory;
3433
import javax.jcr.ValueFormatException;
35-
import org.apache.commons.collections4.CollectionUtils;
3634
import org.apache.commons.lang3.StringUtils;
3735

3836
public class Restrictions {
@@ -62,17 +60,10 @@ public class Restrictions {
6260

6361
public Restrictions(String glob, List<String> ntNames, List<String> itemNames, Map<String, Object> customRestrictions) {
6462
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());
7667
}
7768

7869
public Map<String, Value> getSingleValueRestrictions(ValueFactory valueFactory) throws ValueFormatException {
@@ -93,7 +84,7 @@ public Map<String, Value> getSingleValueRestrictions(ValueFactory valueFactory)
9384
}
9485

9586
private void addRestriction(ValueFactory valueFactory, Map<String, Value> result, String key, String value) throws ValueFormatException {
96-
if (StringUtils.isNotBlank(value)) {
87+
if (value != null) {
9788
result.put(key, createValue(valueFactory, key, value));
9889
}
9990
}
@@ -132,7 +123,7 @@ public Map<String, Value[]> getMultiValueRestrictions(ValueFactory valueFactory)
132123
}
133124

134125
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) {
136127
result.put(key, createRestrictions(valueFactory, key, names));
137128
}
138129
}

0 commit comments

Comments
 (0)