Class CacheApiSettings

java.lang.Object
io.github.xanthic.cache.core.CacheApiSettings

public final class CacheApiSettings extends Object
Holds a registry of default settings and cache providers.
  • Method Details

    • setDefaultCacheProvider

      public void setDefaultCacheProvider(@NotNull @NotNull io.github.xanthic.cache.api.CacheProvider provider)
      Sets the default cache provider to use for caches that don't explicitly specify a provider to use.
      Parameters:
      provider - the cache provider to be the new default
      Throws:
      NullPointerException - if the provider argument is null
    • getDefaultCacheProvider

      @NotNull public @NotNull io.github.xanthic.cache.api.CacheProvider getDefaultCacheProvider()
      Obtains the default cache provider.
      Returns:
      an instance of the default cache provider
      Throws:
      io.github.xanthic.cache.api.exception.NoDefaultCacheImplementationException - if no default has been set
      See Also:
    • registerCacheProvider

      public void registerCacheProvider(@NonNull @NonNull Class<? extends io.github.xanthic.cache.api.CacheProvider> cacheProviderClass, @Nullable @Nullable io.github.xanthic.cache.api.CacheProvider cacheProvider)
      Registers an available provider for the cache settings.

      Further, the default cache provider will be set to this cache provider, if the default has not yet been set.

      Note: the cacheProvider parameter can only be null if there is a public no-args constructor for the provider. This allows for lazy initialization of the provider only if it is needed.

      Parameters:
      cacheProviderClass - the class of the provider
      cacheProvider - an instance of the provider
      Throws:
      NullPointerException - if cacheProviderClass is null
    • getInstance

      @NotNull public static @NotNull CacheApiSettings getInstance()
      Returns:
      the cache api settings singleton
    • getDefaultMisconfigurationPolicy

      public io.github.xanthic.cache.api.domain.MisconfigurationPolicy getDefaultMisconfigurationPolicy()
      The default misconfiguration policy.
      See Also:
      • MisconfigurationPolicy
    • setDefaultMisconfigurationPolicy

      public void setDefaultMisconfigurationPolicy(io.github.xanthic.cache.api.domain.MisconfigurationPolicy defaultMisconfigurationPolicy)
      The default misconfiguration policy.
      See Also:
      • MisconfigurationPolicy