Skip to content

Commit a2ce53a

Browse files
committed
fixup: apply changes
Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
1 parent 7d19751 commit a2ce53a

File tree

96 files changed

+2142
-1423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+2142
-1423
lines changed

src/main/java/dev/openfeature/sdk/AbstractStructure.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.HashMap;
44
import java.util.Map;
55

6-
@SuppressWarnings({ "PMD.BeanMembersShouldSerialize", "checkstyle:MissingJavadocType" })
6+
@SuppressWarnings({"PMD.BeanMembersShouldSerialize", "checkstyle:MissingJavadocType"})
77
abstract class AbstractStructure implements Structure {
88

99
protected final Map<String, Value> attributes;
@@ -23,12 +23,11 @@ abstract class AbstractStructure implements Structure {
2323
*/
2424
@Override
2525
public Map<String, Object> asObjectMap() {
26-
return attributes
27-
.entrySet()
28-
.stream()
26+
return attributes.entrySet().stream()
2927
// custom collector, workaround for Collectors.toMap in JDK8
3028
// https://bugs.openjdk.org/browse/JDK-8148463
31-
.collect(HashMap::new,
29+
.collect(
30+
HashMap::new,
3231
(accumulated, entry) -> accumulated.put(entry.getKey(), convertValue(entry.getValue())),
3332
HashMap::putAll);
3433
}

src/main/java/dev/openfeature/sdk/BooleanHook.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* An extension point which can run around flag resolution. They are intended to be used as a way to add custom logic
55
* to the lifecycle of flag evaluation.
6-
*
6+
*
77
* @see Hook
88
*/
99
public interface BooleanHook extends Hook<Boolean> {

src/main/java/dev/openfeature/sdk/DoubleHook.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* An extension point which can run around flag resolution. They are intended to be used as a way to add custom logic
55
* to the lifecycle of flag evaluation.
6-
*
6+
*
77
* @see Hook
88
*/
99
public interface DoubleHook extends Hook<Double> {
@@ -12,4 +12,4 @@ public interface DoubleHook extends Hook<Double> {
1212
default boolean supportsFlagValueType(FlagValueType flagValueType) {
1313
return FlagValueType.DOUBLE == flagValueType;
1414
}
15-
}
15+
}

src/main/java/dev/openfeature/sdk/ErrorCode.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@
22

33
@SuppressWarnings("checkstyle:MissingJavadocType")
44
public enum ErrorCode {
5-
PROVIDER_NOT_READY, FLAG_NOT_FOUND, PARSE_ERROR, TYPE_MISMATCH, TARGETING_KEY_MISSING, INVALID_CONTEXT, GENERAL
5+
PROVIDER_NOT_READY,
6+
FLAG_NOT_FOUND,
7+
PARSE_ERROR,
8+
TYPE_MISMATCH,
9+
TARGETING_KEY_MISSING,
10+
INVALID_CONTEXT,
11+
GENERAL
612
}

src/main/java/dev/openfeature/sdk/EventBus.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,56 @@
66
* Interface for attaching event handlers.
77
*/
88
public interface EventBus<T> {
9-
9+
1010
/**
1111
* Add a handler for the {@link ProviderEvent#PROVIDER_READY} event.
1212
* Shorthand for {@link #on(ProviderEvent, Consumer)}
13-
*
13+
*
1414
* @param handler behavior to add with this event
1515
* @return this
1616
*/
1717
T onProviderReady(Consumer<EventDetails> handler);
18-
18+
1919
/**
2020
* Add a handler for the {@link ProviderEvent#PROVIDER_CONFIGURATION_CHANGED} event.
2121
* Shorthand for {@link #on(ProviderEvent, Consumer)}
22-
*
22+
*
2323
* @param handler behavior to add with this event
2424
* @return this
2525
*/
2626
T onProviderConfigurationChanged(Consumer<EventDetails> handler);
27-
27+
2828
/**
2929
* Add a handler for the {@link ProviderEvent#PROVIDER_STALE} event.
3030
* Shorthand for {@link #on(ProviderEvent, Consumer)}
31-
*
31+
*
3232
* @param handler behavior to add with this event
3333
* @return this
3434
*/
3535
T onProviderError(Consumer<EventDetails> handler);
36-
36+
3737
/**
3838
* Add a handler for the {@link ProviderEvent#PROVIDER_ERROR} event.
3939
* Shorthand for {@link #on(ProviderEvent, Consumer)}
40-
*
40+
*
4141
* @param handler behavior to add with this event
4242
* @return this
4343
*/
4444
T onProviderStale(Consumer<EventDetails> handler);
4545

4646
/**
4747
* Add a handler for the specified {@link ProviderEvent}.
48-
*
48+
*
4949
* @param event event type
5050
* @param handler behavior to add with this event
5151
* @return this
5252
*/
5353
T on(ProviderEvent event, Consumer<EventDetails> handler);
54-
54+
5555
/**
5656
* Remove the previously attached handler by reference.
5757
* If the handler doesn't exists, no-op.
58-
*
58+
*
5959
* @param event event type
6060
* @param handler to be removed
6161
* @return this

src/main/java/dev/openfeature/sdk/EventDetails.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ static EventDetails fromProviderEventDetails(ProviderEventDetails providerEventD
1717
}
1818

1919
static EventDetails fromProviderEventDetails(
20-
ProviderEventDetails providerEventDetails,
21-
String providerName,
22-
String domain) {
20+
ProviderEventDetails providerEventDetails, String providerName, String domain) {
2321
return builder()
2422
.domain(domain)
2523
.providerName(providerName)

src/main/java/dev/openfeature/sdk/EventProvider.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public abstract class EventProvider implements FeatureProvider {
2626

2727
/**
2828
* "Attach" this EventProvider to an SDK, which allows events to propagate from this provider.
29-
* No-op if the same onEmit is already attached.
29+
* No-op if the same onEmit is already attached.
3030
*
3131
* @param onEmit the function to run when a provider emits events.
3232
* @throws IllegalStateException if attempted to bind a new emitter for already bound provider
@@ -50,7 +50,7 @@ void detach() {
5050

5151
/**
5252
* Emit the specified {@link ProviderEvent}.
53-
*
53+
*
5454
* @param event The event type
5555
* @param details The details of the event
5656
*/
@@ -63,7 +63,7 @@ public void emit(ProviderEvent event, ProviderEventDetails details) {
6363
/**
6464
* Emit a {@link ProviderEvent#PROVIDER_READY} event.
6565
* Shorthand for {@link #emit(ProviderEvent, ProviderEventDetails)}
66-
*
66+
*
6767
* @param details The details of the event
6868
*/
6969
public void emitProviderReady(ProviderEventDetails details) {
@@ -74,7 +74,7 @@ public void emitProviderReady(ProviderEventDetails details) {
7474
* Emit a
7575
* {@link ProviderEvent#PROVIDER_CONFIGURATION_CHANGED}
7676
* event. Shorthand for {@link #emit(ProviderEvent, ProviderEventDetails)}
77-
*
77+
*
7878
* @param details The details of the event
7979
*/
8080
public void emitProviderConfigurationChanged(ProviderEventDetails details) {
@@ -84,7 +84,7 @@ public void emitProviderConfigurationChanged(ProviderEventDetails details) {
8484
/**
8585
* Emit a {@link ProviderEvent#PROVIDER_STALE} event.
8686
* Shorthand for {@link #emit(ProviderEvent, ProviderEventDetails)}
87-
*
87+
*
8888
* @param details The details of the event
8989
*/
9090
public void emitProviderStale(ProviderEventDetails details) {
@@ -94,7 +94,7 @@ public void emitProviderStale(ProviderEventDetails details) {
9494
/**
9595
* Emit a {@link ProviderEvent#PROVIDER_ERROR} event.
9696
* Shorthand for {@link #emit(ProviderEvent, ProviderEventDetails)}
97-
*
97+
*
9898
* @param details The details of the event
9999
*/
100100
public void emitProviderError(ProviderEventDetails details) {

src/main/java/dev/openfeature/sdk/EventSupport.java

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package dev.openfeature.sdk;
22

3-
import lombok.extern.slf4j.Slf4j;
4-
53
import java.util.ArrayList;
64
import java.util.List;
75
import java.util.Map;
@@ -13,6 +11,7 @@
1311
import java.util.concurrent.Executors;
1412
import java.util.concurrent.TimeUnit;
1513
import java.util.function.Consumer;
14+
import lombok.extern.slf4j.Slf4j;
1615

1716
/**
1817
* Util class for storing and running handlers.
@@ -35,74 +34,68 @@ class EventSupport {
3534
/**
3635
* Run all the event handlers associated with this domain.
3736
* If the domain is null, handlers attached to unnamed clients will run.
38-
*
37+
*
3938
* @param domain the domain to run event handlers for, or null
4039
* @param event the event type
4140
* @param eventDetails the event details
4241
*/
4342
public void runClientHandlers(String domain, ProviderEvent event, EventDetails eventDetails) {
44-
domain = Optional.ofNullable(domain)
45-
.orElse(defaultClientUuid);
43+
domain = Optional.ofNullable(domain).orElse(defaultClientUuid);
4644

4745
// run handlers if they exist
4846
Optional.ofNullable(handlerStores.get(domain))
4947
.filter(store -> Optional.of(store).isPresent())
5048
.map(store -> store.handlerMap.get(event))
51-
.ifPresent(handlers -> handlers
52-
.forEach(handler -> runHandler(handler, eventDetails)));
49+
.ifPresent(handlers -> handlers.forEach(handler -> runHandler(handler, eventDetails)));
5350
}
5451

5552
/**
5653
* Run all the API (global) event handlers.
57-
*
54+
*
5855
* @param event the event type
5956
* @param eventDetails the event details
6057
*/
6158
public void runGlobalHandlers(ProviderEvent event, EventDetails eventDetails) {
62-
globalHandlerStore.handlerMap.get(event)
63-
.forEach(handler -> {
64-
runHandler(handler, eventDetails);
65-
});
59+
globalHandlerStore.handlerMap.get(event).forEach(handler -> {
60+
runHandler(handler, eventDetails);
61+
});
6662
}
6763

6864
/**
6965
* Add a handler for the specified domain, or all unnamed clients.
70-
*
66+
*
7167
* @param domain the domain to add handlers for, or else unnamed
7268
* @param event the event type
7369
* @param handler the handler function to run
7470
*/
7571
public void addClientHandler(String domain, ProviderEvent event, Consumer<EventDetails> handler) {
76-
final String name = Optional.ofNullable(domain)
77-
.orElse(defaultClientUuid);
72+
final String name = Optional.ofNullable(domain).orElse(defaultClientUuid);
7873

7974
// lazily create and cache a HandlerStore if it doesn't exist
80-
HandlerStore store = Optional.ofNullable(this.handlerStores.get(name))
81-
.orElseGet(() -> {
82-
HandlerStore newStore = new HandlerStore();
83-
this.handlerStores.put(name, newStore);
84-
return newStore;
85-
});
75+
HandlerStore store = Optional.ofNullable(this.handlerStores.get(name)).orElseGet(() -> {
76+
HandlerStore newStore = new HandlerStore();
77+
this.handlerStores.put(name, newStore);
78+
return newStore;
79+
});
8680
store.addHandler(event, handler);
8781
}
8882

8983
/**
9084
* Remove a client event handler for the specified event type.
91-
*
85+
*
9286
* @param domain the domain of the client handler to remove, or null to remove
9387
* from unnamed clients
9488
* @param event the event type
9589
* @param handler the handler ref to be removed
9690
*/
9791
public void removeClientHandler(String domain, ProviderEvent event, Consumer<EventDetails> handler) {
98-
domain = Optional.ofNullable(domain)
99-
.orElse(defaultClientUuid);
92+
domain = Optional.ofNullable(domain).orElse(defaultClientUuid);
10093
this.handlerStores.get(domain).removeHandler(event, handler);
10194
}
10295

10396
/**
10497
* Add a global event handler of the specified event type.
105-
*
98+
*
10699
* @param event the event type
107100
* @param handler the handler to be added
108101
*/
@@ -112,7 +105,7 @@ public void addGlobalHandler(ProviderEvent event, Consumer<EventDetails> handler
112105

113106
/**
114107
* Remove a global event handler for the specified event type.
115-
*
108+
*
116109
* @param event the event type
117110
* @param handler the handler ref to be removed
118111
*/
@@ -122,7 +115,7 @@ public void removeGlobalHandler(ProviderEvent event, Consumer<EventDetails> hand
122115

123116
/**
124117
* Get all domain names for which we have event handlers registered.
125-
*
118+
*
126119
* @return set of domain names
127120
*/
128121
public Set<String> getAllDomainNames() {
@@ -131,7 +124,7 @@ public Set<String> getAllDomainNames() {
131124

132125
/**
133126
* Run the passed handler on the taskExecutor.
134-
*
127+
*
135128
* @param handler the handler to run
136129
* @param eventDetails the event details
137130
*/

src/main/java/dev/openfeature/sdk/FeatureProvider.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@ default void shutdown() {
6060
* If the provider needs to be initialized, it should return {@link ProviderState#NOT_READY}.
6161
* If the provider is in an error state, it should return {@link ProviderState#ERROR}.
6262
* If the provider is functioning normally, it should return {@link ProviderState#READY}.
63-
*
63+
*
6464
* <p><i>Providers which do not implement this method are assumed to be ready immediately.</i></p>
65-
*
65+
*
6666
* @return ProviderState
6767
*/
6868
default ProviderState getState() {
6969
return ProviderState.READY;
7070
}
71-
7271
}

0 commit comments

Comments
 (0)