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

net.sf.javagimmicks.util.ConstantSupplier Maven / Gradle / Ivy

There is a newer version: 0.99-alpha1
Show newest version
package net.sf.javagimmicks.util;

/**
 * An implementation of {@link Supplier} which holds a constant object of the
 * required type and returns it upon every call to {@link #get()}
 */
public class ConstantSupplier implements Supplier
{
   private final E _value;

   /**
    * Create a new instance for the given constant value
    * 
    * @param value
    *           the value to use for every creation call
    */
   public ConstantSupplier(final E value)
   {
      _value = value;
   }

   @Override
   public E get()
   {
      return _value;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy