Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 31c83c8

Browse files
author
Dan Richelson
committed
Convert parameterized constructors to less verbose Java7 style.
1 parent 3f64c2e commit 31c83c8

File tree

11 files changed

+30
-30
lines changed

11 files changed

+30
-30
lines changed

src/main/java/com/launchdarkly/client/EventProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class EventProcessor implements Closeable {
2525

2626
EventProcessor(String apiKey, LDConfig config) {
2727
this.apiKey = apiKey;
28-
this.queue = new ArrayBlockingQueue<Event>(config.capacity);
28+
this.queue = new ArrayBlockingQueue<>(config.capacity);
2929
this.consumer = new Consumer(config);
3030
this.scheduler.scheduleAtFixedRate(consumer, 0, config.flushInterval, TimeUnit.SECONDS);
3131
}
@@ -70,7 +70,7 @@ public void run() {
7070
}
7171

7272
public void flush() {
73-
List<Event> events = new ArrayList<Event>(queue.size());
73+
List<Event> events = new ArrayList<>(queue.size());
7474
queue.drainTo(events);
7575

7676
if (!events.isEmpty()) {

src/main/java/com/launchdarkly/client/EventSource.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ private static enum State {
5555
/**
5656
* Event source internal state.
5757
*/
58-
private final AtomicReference<State> state = new AtomicReference<State>(State.READY);
58+
private final AtomicReference<State> state = new AtomicReference<>(State.READY);
5959
/**
6060
* List of all listeners not bound to receive only events of a particular name.
6161
*/
62-
private final List<EventListener> unboundListeners = new CopyOnWriteArrayList<EventListener>();
62+
private final List<EventListener> unboundListeners = new CopyOnWriteArrayList<>();
6363
/**
6464
* A map of listeners bound to receive only events of a particular name.
6565
*/
66-
private final ConcurrentMap<String, List<EventListener>> boundListeners = new ConcurrentHashMap<String, List<EventListener>>();
66+
private final ConcurrentMap<String, List<EventListener>> boundListeners = new ConcurrentHashMap<>();
6767

6868
private final MultivaluedMap<String, Object> headers;
6969

@@ -96,7 +96,7 @@ private Builder(final WebTarget endpoint) {
9696
this.endpoint = endpoint;
9797
}
9898

99-
private MultivaluedMap<String, Object> headers = new StringKeyIgnoreCaseMultivaluedMap<Object>();
99+
private MultivaluedMap<String, Object> headers = new StringKeyIgnoreCaseMultivaluedMap<>();
100100

101101
/**
102102
* Set a custom name for the event source.
@@ -233,7 +233,7 @@ public static Builder target(WebTarget endpoint) {
233233
* @throws NullPointerException in case the supplied web target is {@code null}.
234234
*/
235235
public EventSource(final WebTarget endpoint) {
236-
this(endpoint, true, new StringKeyIgnoreCaseMultivaluedMap<Object>());
236+
this(endpoint, true, new StringKeyIgnoreCaseMultivaluedMap<>());
237237
}
238238

239239
/**
@@ -293,7 +293,7 @@ public Thread newThread(Runnable r) {
293293
}
294294
});
295295

296-
this.headers = new StringKeyIgnoreCaseMultivaluedMap<Object>();
296+
this.headers = new StringKeyIgnoreCaseMultivaluedMap<>();
297297
this.headers.putAll(headers);
298298

299299
if (open) {
@@ -373,7 +373,7 @@ public void register(final EventListener listener, final String eventName, final
373373

374374
private void addBoundListener(final String name, final EventListener listener) {
375375
List<EventListener> listeners = boundListeners.putIfAbsent(name,
376-
new CopyOnWriteArrayList<EventListener>(Collections.singleton(listener)));
376+
new CopyOnWriteArrayList<>(Collections.singleton(listener)));
377377
if (listeners != null) {
378378
// alas, new listener collection registration conflict:
379379
// need to add the new listener to the existing listener collection

src/main/java/com/launchdarkly/client/FeatureRep.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public int hashCode() {
7070
this.on = b.on;
7171
this.deleted = b.deleted;
7272
this.version = b.version;
73-
this.variations = new ArrayList<Variation<E>>(b.variations);
73+
this.variations = new ArrayList<>(b.variations);
7474
}
7575

7676
private Float paramForUser(LDUser user) {
@@ -147,7 +147,7 @@ static class Builder<E> {
147147
this.name = name;
148148
this.key = key;
149149
this.salt = UUID.randomUUID().toString();
150-
this.variations = new ArrayList<Variation<E>>();
150+
this.variations = new ArrayList<>();
151151
}
152152

153153
Builder<E> salt(String s) {
@@ -176,7 +176,7 @@ Builder<E> version(int v) {
176176
}
177177

178178
FeatureRep<E> build() {
179-
return new FeatureRep<E>(this);
179+
return new FeatureRep<>(this);
180180
}
181181

182182
}

src/main/java/com/launchdarkly/client/InMemoryFeatureStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class InMemoryFeatureStore implements FeatureStore {
1414

1515
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
16-
final Map<String, FeatureRep<?>> features = new HashMap<String, FeatureRep<?>>();
16+
final Map<String, FeatureRep<?>> features = new HashMap<>();
1717
volatile boolean initialized = false;
1818

1919

@@ -52,7 +52,7 @@ public FeatureRep<?> get(String key) {
5252
public Map<String, FeatureRep<?>> all() {
5353
try {
5454
lock.readLock().lock();
55-
Map<String, FeatureRep<?>> fs = new HashMap<String, FeatureRep<?>>();
55+
Map<String, FeatureRep<?>> fs = new HashMap<>();
5656

5757
for (Map.Entry<String, FeatureRep<?>> entry : features.entrySet()) {
5858
if (!entry.getValue().deleted) {

src/main/java/com/launchdarkly/client/LDClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void identify(LDUser user) {
116116
}
117117

118118
private void sendFlagRequestEvent(String featureKey, LDUser user, boolean value, boolean defaultValue) {
119-
boolean processed = eventProcessor.sendEvent(new FeatureRequestEvent<Boolean>(featureKey, user, value, defaultValue));
119+
boolean processed = eventProcessor.sendEvent(new FeatureRequestEvent<>(featureKey, user, value, defaultValue));
120120
if (!processed) {
121121
logger.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.");
122122
}

src/main/java/com/launchdarkly/client/LDCountryCode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,8 +2131,8 @@ enum Assignment
21312131
}
21322132

21332133

2134-
private static final Map<String, LDCountryCode> alpha3Map = new HashMap<String, LDCountryCode>();
2135-
private static final Map<Integer, LDCountryCode> numericMap = new HashMap<Integer, LDCountryCode>();
2134+
private static final Map<String, LDCountryCode> alpha3Map = new HashMap<>();
2135+
private static final Map<Integer, LDCountryCode> numericMap = new HashMap<>();
21362136

21372137

21382138
static
@@ -2640,7 +2640,7 @@ public static List<LDCountryCode> findByName(Pattern pattern)
26402640
throw new IllegalArgumentException("pattern is null.");
26412641
}
26422642

2643-
List<LDCountryCode> list = new ArrayList<LDCountryCode>();
2643+
List<LDCountryCode> list = new ArrayList<>();
26442644

26452645
for (LDCountryCode entry : values())
26462646
{

src/main/java/com/launchdarkly/client/LDUser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected LDUser(Builder builder) {
5454
this.name = builder.name == null ? null : new JsonPrimitive(builder.name);
5555
this.avatar = builder.avatar == null ? null : new JsonPrimitive(builder.avatar);
5656
this.anonymous = builder.anonymous == null ? null : new JsonPrimitive(builder.anonymous);
57-
this.custom = new HashMap<String, JsonElement>(builder.custom);
57+
this.custom = new HashMap<>(builder.custom);
5858
}
5959

6060
/**
@@ -63,7 +63,7 @@ protected LDUser(Builder builder) {
6363
*/
6464
public LDUser(String key) {
6565
this.key = new JsonPrimitive(key);
66-
this.custom = new HashMap<String, JsonElement>();
66+
this.custom = new HashMap<>();
6767
}
6868

6969
JsonPrimitive getKey() {
@@ -123,7 +123,7 @@ public static class Builder {
123123
*/
124124
public Builder(String key) {
125125
this.key = key;
126-
this.custom = new HashMap<String, JsonElement>();
126+
this.custom = new HashMap<>();
127127
}
128128

129129
/**

src/main/java/com/launchdarkly/client/RedisFeatureStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public FeatureRep<?> get(String key) {
160160
public Map<String, FeatureRep<?>> all() {
161161
try (Jedis jedis = pool.getResource()) {
162162
Map<String,String> featuresJson = jedis.hgetAll(featuresKey());
163-
Map<String, FeatureRep<?>> result = new HashMap<String, FeatureRep<?>>();
163+
Map<String, FeatureRep<?>> result = new HashMap<>();
164164
Gson gson = new Gson();
165165

166166
Type type = new TypeToken<FeatureRep<?>>() {}.getType();

src/main/java/com/launchdarkly/client/StreamProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void subscribe() {
4747
return;
4848
}
4949

50-
MultivaluedMap<String, Object> headers = new StringKeyIgnoreCaseMultivaluedMap<Object>();
50+
MultivaluedMap<String, Object> headers = new StringKeyIgnoreCaseMultivaluedMap<>();
5151
headers.putSingle("Authorization", "api_key " + this.apiKey);
5252
headers.putSingle("User-Agent", "JavaClient/" + LDClient.CLIENT_VERSION);
5353
headers.putSingle("Accept", SseFeature.SERVER_SENT_EVENTS_TYPE);

src/main/java/com/launchdarkly/client/Variation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public int hashCode() {
5858
this.value = b.value;
5959
this.weight = b.weight;
6060
this.userTarget = b.userTarget;
61-
this.targets = new ArrayList<TargetRule>(b.targets);
61+
this.targets = new ArrayList<>(b.targets);
6262
}
6363

6464
public boolean matchUser(LDUser user) {
@@ -93,7 +93,7 @@ static class Builder<E> {
9393
this.value = value;
9494
this.weight = weight;
9595
this.userTarget = new TargetRule("key", "in", new ArrayList<JsonPrimitive>());
96-
targets = new ArrayList<TargetRule>();
96+
targets = new ArrayList<>();
9797
}
9898

9999
Builder<E> userTarget(TargetRule rule) {
@@ -107,7 +107,7 @@ Builder<E> target(TargetRule rule) {
107107
}
108108

109109
Variation<E> build() {
110-
return new Variation<E>(this);
110+
return new Variation<>(this);
111111
}
112112

113113
}
@@ -126,7 +126,7 @@ public TargetRule() {
126126
TargetRule(String attribute, String operator, List<JsonPrimitive> values) {
127127
this.attribute = attribute;
128128
this.operator = operator;
129-
this.values = new ArrayList<JsonPrimitive>(values);
129+
this.values = new ArrayList<>(values);
130130
}
131131

132132
TargetRule(String attribute, List<JsonPrimitive> values) {

0 commit comments

Comments
 (0)