All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cloud.prefab.client.internal.ConfigStoreImpl Maven / Gradle / Ivy

Go to download

API Client for https://prefab.cloud: rate limits, feature flags and semaphores as a service

There is a newer version: 0.3.23
Show newest version
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();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy