55import dev .openfeature .sdk .internal .AutoCloseableReentrantReadWriteLock ;
66import lombok .extern .slf4j .Slf4j ;
77
8- import java .util .ArrayList ;
9- import java .util .Arrays ;
10- import java .util .List ;
11- import java .util .Optional ;
12- import java .util .Set ;
8+ import java .util .*;
139import java .util .function .Consumer ;
1410
1511/**
@@ -69,7 +65,7 @@ public Metadata getProviderMetadata(String domain) {
6965 }
7066
7167 /**
72- * A factory function for creating new, OpenFeature clients .
68+ * A factory function for creating new, OpenFeature client .
7369 * Clients can contain their own state (e.g. logger, hook, context).
7470 * Multiple clients can be used to segment feature flag configuration.
7571 * All un-named or unbound clients use the default provider.
@@ -81,12 +77,12 @@ public Client getClient() {
8177 }
8278
8379 /**
84- * A factory function for creating new domainless OpenFeature clients .
80+ * A factory function for creating new domainless OpenFeature client .
8581 * Clients can contain their own state (e.g. logger, hook, context).
8682 * Multiple clients can be used to segment feature flag configuration.
8783 * If there is already a provider bound to this domain, this provider will be used.
8884 * Otherwise, the default provider is used until a provider is assigned to that domain.
89- *
85+ *
9086 * @param domain an identifier which logically binds clients with providers
9187 * @return a new client instance
9288 */
@@ -95,20 +91,22 @@ public Client getClient(String domain) {
9591 }
9692
9793 /**
98- * A factory function for creating new domainless OpenFeature clients .
94+ * A factory function for creating new domainless OpenFeature client .
9995 * Clients can contain their own state (e.g. logger, hook, context).
10096 * Multiple clients can be used to segment feature flag configuration.
10197 * If there is already a provider bound to this domain, this provider will be used.
10298 * Otherwise, the default provider is used until a provider is assigned to that domain.
103- *
104- * @param domain a identifier which logically binds clients with providers
99+ *
100+ * @param domain a identifier which logically binds clients with providers
105101 * @param version a version identifier
106102 * @return a new client instance
107103 */
108104 public Client getClient (String domain , String version ) {
109- return new OpenFeatureClient (this ,
105+ return new OpenFeatureClient (
106+ this ,
110107 domain ,
111- version );
108+ version
109+ );
112110 }
113111
114112 /**
@@ -193,8 +191,8 @@ public void setProvider(FeatureProvider provider) {
193191 /**
194192 * Add a provider for a domain.
195193 *
196- * @param domain The domain to bind the provider to.
197- * @param provider The provider to set.
194+ * @param domain The domain to bind the provider to.
195+ * @param provider The provider to set.
198196 */
199197 public void setProvider (String domain , FeatureProvider provider ) {
200198 try (AutoCloseableLock __ = lock .writeLockAutoCloseable ()) {
@@ -226,8 +224,8 @@ public void setProviderAndWait(FeatureProvider provider) throws OpenFeatureError
226224 /**
227225 * Add a provider for a domain and wait for initialization to finish.
228226 *
229- * @param domain The domain to bind the provider to.
230- * @param provider The provider to set.
227+ * @param domain The domain to bind the provider to.
228+ * @param provider The provider to set.
231229 */
232230 public void setProviderAndWait (String domain , FeatureProvider provider ) throws OpenFeatureError {
233231 try (AutoCloseableLock __ = lock .writeLockAutoCloseable ()) {
@@ -300,6 +298,7 @@ public void addHooks(Hook... hooks) {
300298
301299 /**
302300 * Fetch the hooks associated to this client.
301+ *
303302 * @return A list of {@link Hook}s.
304303 */
305304 public List <Hook > getHooks () {
@@ -394,17 +393,21 @@ void removeHandler(String domain, ProviderEvent event, Consumer<EventDetails> ha
394393 void addHandler (String domain , ProviderEvent event , Consumer <EventDetails > handler ) {
395394 try (AutoCloseableLock __ = lock .writeLockAutoCloseable ()) {
396395 // if the provider is in the state associated with event, run immediately
397- if (Optional .ofNullable (this .providerRepository .getProvider (domain ). getState ( ))
396+ if (Optional .ofNullable (this .providerRepository .getProviderState (domain ))
398397 .orElse (ProviderState .READY ).matchesEvent (event )) {
399398 eventSupport .runHandler (handler , EventDetails .builder ().domain (domain ).build ());
400399 }
401400 eventSupport .addClientHandler (domain , event , handler );
402401 }
403402 }
404403
404+ FeatureProviderStateManager getFeatureProviderStateManager (String domain ) {
405+ return providerRepository .getFeatureProviderStateManager (domain );
406+ }
407+
405408 /**
406409 * Runs the handlers associated with a particular provider.
407- *
410+ *
408411 * @param provider the provider from where this event originated
409412 * @param event the event type
410413 * @param details the event details
0 commit comments