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

net.sf.javagimmicks.lang.WritableObjectContainer Maven / Gradle / Ivy

The newest version!
package net.sf.javagimmicks.lang;

/**
 * This interface extends {@link ObjectContainer} by providing additional
 * methods that allow write access to the contained object.
 * 
 * @param 
 *           the type of object the container can carry
 */
public interface WritableObjectContainer extends ObjectContainer
{
   /**
    * Returns if an already set object instance may be replaced by another one
    * 
    * @return if an already set object instance my be replaced by another one
    * @see #set(Object)
    */
   boolean isAllowOverwrite();

   /**
    * Registers an instance in the container
    * 
    * @param instance
    *           the instance to register
    * @throws IllegalStateException
    *            if the given instances is not null and there is
    *            already another instance registered and
    *            {@link #isAllowOverwrite()} is true
    * @see #isAllowOverwrite()
    */
   void set(E instance) throws IllegalStateException;

   /**
    * Removes the instance (if any) from the container
    * 
    * @return the previously registered instance or null if none
    *         was registered
    */
   E remove();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy