Skip to content

Commit 71c083e

Browse files
committed
removed guava dependency
1 parent ef740b6 commit 71c083e

File tree

9 files changed

+31
-53
lines changed

9 files changed

+31
-53
lines changed

app/aem/core/src/main/java/com/cognifide/apm/core/actions/MapperDescriptorFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
import java.lang.reflect.ParameterizedType;
4343
import java.lang.reflect.Type;
4444
import java.util.ArrayList;
45+
import java.util.Collections;
4546
import java.util.List;
4647
import java.util.Map;
4748
import java.util.Optional;
48-
import org.apache.commons.collections4.ListUtils;
4949

5050
public class MapperDescriptorFactory {
5151

@@ -62,7 +62,7 @@ public MapperDescriptor create(Class<?> mapperClass) {
6262
for (Method method : mapperClass.getDeclaredMethods()) {
6363
create(mapperAnnotation, method).ifPresent(mappingDescriptors::add);
6464
}
65-
return new MapperDescriptor(mapper, name, group, ListUtils.unmodifiableList(mappingDescriptors));
65+
return new MapperDescriptor(mapper, name, group, Collections.unmodifiableList(mappingDescriptors));
6666
}
6767

6868
@SuppressWarnings("deprecation")
@@ -111,7 +111,7 @@ private Optional<MappingDescriptor> create(Mapper mapper, Method method) {
111111
parameterDescriptors.add(parameterDescriptor);
112112
}
113113

114-
return Optional.of(new MappingDescriptor(method, mapper, mapping, ListUtils.unmodifiableList(parameterDescriptors)));
114+
return Optional.of(new MappingDescriptor(method, mapper, mapping, Collections.unmodifiableList(parameterDescriptors)));
115115
}
116116

117117
private <T extends Annotation> T getAnnotation(Annotation[] annotations, Class<T> type) {

app/aem/core/src/main/java/com/cognifide/apm/core/actions/scanner/AnnotatedClassRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
import java.lang.annotation.Annotation;
2323
import java.util.ArrayList;
24+
import java.util.Collections;
2425
import java.util.HashSet;
2526
import java.util.List;
2627
import java.util.Map;
2728
import java.util.Set;
2829
import java.util.concurrent.ConcurrentHashMap;
29-
import org.apache.commons.collections4.ListUtils;
3030
import org.osgi.framework.Bundle;
3131
import org.osgi.framework.BundleContext;
3232
import org.osgi.framework.BundleEvent;
@@ -96,7 +96,7 @@ public List<Class<?>> getClasses() {
9696
flattened.addAll(entry.getValue());
9797
}
9898

99-
return ListUtils.unmodifiableList(flattened);
99+
return Collections.unmodifiableList(flattened);
100100
}
101101

102102
private void registerClasses(Bundle bundle) {

app/aem/core/src/main/java/com/cognifide/apm/core/jobs/JobResultsCache.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
)
3737
public class JobResultsCache {
3838

39-
private static final long TTL = 10 * 60 * 1000;
39+
private static final long DEFAULT_TTL = 10 * 60 * 1000;
4040

4141
private Map<String, ExecutionSummary> cache;
4242

@@ -58,7 +58,7 @@ public ExecutionSummary get(String id) {
5858
private void invalidate() {
5959
long now = System.currentTimeMillis();
6060
cache.forEach((key, value) -> {
61-
if (value.time + TTL < now) {
61+
if (value.timestamp + DEFAULT_TTL < now) {
6262
cache.remove(key);
6363
}
6464
});
@@ -69,13 +69,13 @@ public static class ExecutionSummary implements Serializable {
6969
private final boolean finished;
7070
private final ExecutionResult result;
7171
private final String path;
72-
private final long time;
72+
private final long timestamp;
7373

7474
private ExecutionSummary(boolean finished, ExecutionResult result, String path) {
7575
this.finished = finished;
7676
this.result = result;
7777
this.path = path;
78-
this.time = System.currentTimeMillis();
78+
this.timestamp = System.currentTimeMillis();
7979
}
8080

8181
public static ExecutionSummary running() {

app/aem/core/src/main/java/com/cognifide/apm/core/logger/ProgressEntry.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.cognifide.apm.api.status.Status;
2424
import java.util.Collections;
2525
import java.util.List;
26-
import org.apache.commons.collections4.ListUtils;
2726
import org.apache.commons.lang3.StringUtils;
2827

2928
public class ProgressEntry implements Entry {
@@ -45,8 +44,8 @@ public ProgressEntry(Status status, List<String> messages, String command, Strin
4544
this.status = status != null ? status : Status.SUCCESS;
4645
this.command = StringUtils.defaultString(command);
4746
this.position = position;
48-
this.messages = messages != null ? ListUtils.unmodifiableList(messages) : Collections.emptyList();
49-
this.parameters = parameters != null ? ListUtils.unmodifiableList(parameters) : Collections.emptyList();
47+
this.messages = messages != null ? Collections.unmodifiableList(messages) : Collections.emptyList();
48+
this.parameters = parameters != null ? Collections.unmodifiableList(parameters) : Collections.emptyList();
5049
this.authorizable = StringUtils.defaultString(authorizable);
5150
}
5251

app/aem/core/src/main/java/com/cognifide/apm/core/scripts/ScriptModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
import java.util.Arrays;
3333
import java.util.Calendar;
3434
import java.util.Date;
35+
import java.util.HashSet;
3536
import java.util.List;
3637
import java.util.Objects;
3738
import java.util.Optional;
3839
import java.util.Set;
39-
import java.util.stream.Collectors;
4040
import javax.annotation.PostConstruct;
4141
import javax.inject.Inject;
4242
import javax.inject.Named;
@@ -159,7 +159,7 @@ public LaunchEnvironment getLaunchEnvironment() {
159159

160160
@Override
161161
public Set<String> getLaunchRunModes() {
162-
return launchRunModes == null ? null : Arrays.stream(launchRunModes).collect(Collectors.toSet());
162+
return launchRunModes == null ? null : new HashSet<>(Arrays.asList(launchRunModes));
163163
}
164164

165165
@Override

app/aem/core/src/main/java/com/cognifide/apm/core/services/event/ApmEvent.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,33 @@ public abstract class ApmEvent {
3636

3737
private final String topic;
3838

39-
private final Map<String, Object> properties;
39+
protected final Map<String, Object> properties;
4040

4141
private ApmEvent(String topic, Map<String, Object> properties) {
4242
this.topic = topic;
4343
this.properties = properties;
4444
}
4545

46-
private ApmEvent(String topic) {
47-
this(topic, new HashMap<>());
48-
}
49-
50-
protected void putProperty(String key, Object value) {
51-
properties.put(key, value);
52-
}
53-
5446
public Event toOsgiEvent() {
5547
return new Event(topic, properties);
5648
}
5749

5850
public static class ScriptLaunchedEvent extends ApmEvent {
5951

6052
public ScriptLaunchedEvent(Script script, ExecutionMode mode) {
61-
super(SCRIPT_LAUNCHED);
62-
putProperty("script", script.getPath());
63-
putProperty("mode", mode.toString());
53+
super(SCRIPT_LAUNCHED, new HashMap<>());
54+
properties.put("script", script.getPath());
55+
properties.put("mode", mode.toString());
6456
}
6557
}
6658

6759
public static class ScriptExecutedEvent extends ApmEvent {
6860

6961
public ScriptExecutedEvent(Script script, ExecutionMode mode, boolean success) {
70-
super(SCRIPT_EXECUTED);
71-
putProperty("script", script.getPath());
72-
putProperty("mode", mode.toString());
73-
putProperty("success", success);
62+
super(SCRIPT_EXECUTED, new HashMap<>());
63+
properties.put("script", script.getPath());
64+
properties.put("mode", mode.toString());
65+
properties.put("success", success);
7466
}
7567
}
7668

app/aem/core/src/main/java/com/cognifide/apm/core/ui/models/ScriptsRowModel.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.cognifide.apm.core.utils.LabelUtils;
2929
import com.day.cq.commons.jcr.JcrConstants;
3030
import java.util.ArrayList;
31+
import java.util.Arrays;
3132
import java.util.Calendar;
3233
import java.util.Collections;
3334
import java.util.HashSet;
@@ -48,14 +49,8 @@
4849
@Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
4950
public final class ScriptsRowModel {
5051

51-
private static final Set<String> FOLDER_TYPES;
52-
static {
53-
Set<String> tempSet = new HashSet<>();
54-
tempSet.add(JcrConstants.NT_FOLDER);
55-
tempSet.add("sling:OrderedFolder");
56-
tempSet.add("sling:Folder");
57-
FOLDER_TYPES = Collections.unmodifiableSet(tempSet);
58-
}
52+
private static final Set<String> FOLDER_TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
53+
JcrConstants.NT_FOLDER, "sling:OrderedFolder", "sling:Folder")));
5954

6055
public static final String SCRIPTS_ROW_RESOURCE_TYPE = "apm/components/scriptsRow";
6156

app/aem/core/src/main/java/com/cognifide/apm/main/CompositeAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
import com.cognifide.apm.api.exceptions.ActionExecutionException;
2626
import java.util.ArrayList;
2727
import java.util.Arrays;
28+
import java.util.Collections;
2829
import java.util.List;
29-
import org.apache.commons.collections4.ListUtils;
3030

3131
public class CompositeAction implements Action {
3232

3333
private final List<Action> actions;
3434

3535
public CompositeAction(List<Action> actions) {
36-
this.actions = ListUtils.unmodifiableList(actions);
36+
this.actions = Collections.unmodifiableList(actions);
3737
}
3838

3939
public CompositeAction(Action... actions) {

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

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

23+
import java.util.Arrays;
2324
import java.util.Collections;
2425
import java.util.HashMap;
2526
import java.util.HashSet;
@@ -45,19 +46,10 @@ public class Restrictions {
4546

4647
private static final String REP_ITEM_NAMES_PROPERTY = "rep:itemNames";
4748

48-
private static final Set<String> MULTI_VALUE_REP_PROPERTIES;
49-
static {
50-
Set<String> tempSet = new HashSet<>();
51-
tempSet.add(REP_NT_NAMES_PROPERTY);
52-
tempSet.add(REP_ITEM_NAMES_PROPERTY);
53-
tempSet.add(REP_GLOBS_PROPERTY);
54-
tempSet.add("rep:prefixes");
55-
tempSet.add("rep:current");
56-
tempSet.add("rep:subtrees");
57-
tempSet.add("sling:resourceTypes");
58-
tempSet.add("sling:resourceTypesWithDescendants");
59-
MULTI_VALUE_REP_PROPERTIES = Collections.unmodifiableSet(tempSet);
60-
}
49+
private static final Set<String> MULTI_VALUE_REP_PROPERTIES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
50+
REP_NT_NAMES_PROPERTY, REP_ITEM_NAMES_PROPERTY, REP_GLOBS_PROPERTY, "rep:prefixes", "rep:current", "rep:subtrees",
51+
"sling:resourceTypes", "sling:resourceTypesWithDescendants"
52+
)));
6153

6254
private final String glob;
6355

0 commit comments

Comments
 (0)