cloud.prefab.client.internal.ConfigStoreImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of client Show documentation
Show all versions of client Show documentation
API Client for https://prefab.cloud: rate limits, feature flags and semaphores as a service
package cloud.prefab.client.internal;
import cloud.prefab.client.ConfigStore;
import cloud.prefab.client.config.ConfigElement;
import cloud.prefab.context.PrefabContextSetReadable;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
public class ConfigStoreImpl implements ConfigStore {
private final AtomicReference data = new AtomicReference<>(
new MergedConfigData(
Map.of(),
0,
PrefabContextSetReadable.EMPTY,
PrefabContextSetReadable.EMPTY
)
);
@Override
public Collection getKeys() {
return data.get().getConfigs().keySet();
}
public Set> entrySet() {
return data.get().getConfigs().entrySet();
}
@Override
public Collection getElements() {
return data.get().getConfigs().values();
}
public void set(MergedConfigData mergedConfigData) {
data.set(mergedConfigData);
}
@Override
public ConfigElement getElement(String key) {
return data.get().getConfigs().get(key);
}
@Override
public boolean containsKey(String key) {
return data.get().getConfigs().containsKey(key);
}
@Override
public long getProjectEnvironmentId() {
return data.get().getEnvId();
}
@Override
public PrefabContextSetReadable getConfigIncludedContext() {
return data.get().getConfigIncludedContext();
}
@Override
public PrefabContextSetReadable getGlobalContext() {
return data.get().getGlobalContextSet();
}
}