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

org.infinispan.api.common.CacheOptions Maven / Gradle / Ivy

The newest version!
package org.infinispan.api.common;

import java.time.Duration;
import java.util.Optional;

/**
 * @since 14.0
 **/
public interface CacheOptions {
   CacheOptions DEFAULT = new Impl();

   static Builder options() {
      return new Builder();
   }

   Optional timeout();

   Optional> flags();

   class Impl implements CacheOptions {
      private final Duration timeout;
      private final Flags flags;

      protected Impl() {
         this(null, null);
      }

      protected Impl(Duration timeout, Flags flags) {
         this.timeout = timeout;
         this.flags = flags;
      }

      @Override
      public Optional timeout() {
         return Optional.ofNullable(timeout);
      }

      public Duration rawTimeout() {
         return timeout;
      }

      @Override
      public Optional> flags() {
         return Optional.ofNullable(flags);
      }

      public Flags rawFlags() {
         return flags;
      }
   }

   class Builder {
      protected Duration timeout;
      protected Flags flags;

      public Builder timeout(Duration timeout) {
         this.timeout = timeout;
         return this;
      }

      public Builder flags(Flags flags) {
         this.flags.addAll((Flags) flags);
         return this;
      }

      public CacheOptions build() {
         return new Impl(timeout, flags);
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy