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

cloud.prefab.context.ContextStore 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.context;

import java.util.Optional;

public interface ContextStore {
  /**
   * Adds a context to the set of contexts for the current context-session scope
   * If there's already a context with the same type stored in the scope,
   * it is overwritten
   * @param prefabContext a context -
   */
  void addContext(PrefabContext prefabContext);

  /**
   * Overwrites any existing context with the provided context
   * @param prefabContextSetReadable
   * @return existing context, if present
   */
  Optional setContext(
    PrefabContextSetReadable prefabContextSetReadable
  );

  /**
   * Removes all prefab contexts the current context session scope
   * (By default, this is stored in a ThreadLocal)
   * @return existing context, if present
   */
  Optional clearContext();

  /**
   *
   * @return unmodifiable PrefabContextSetReadable view
   */
  Optional getContext();

  /**
   *
   * @return true or false to indicate if the underlying platform feature for a given ContextStore is available
   */

  default boolean isAvailable() {
    return true;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy