net.sf.javagimmicks.util8.WritableSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gimmicks Show documentation
Show all versions of gimmicks Show documentation
Utility classes, APIs and tools for Java
package net.sf.javagimmicks.util8;
import java.util.function.Consumer;
import java.util.function.Supplier;
/**
* This interface extends {@link Supplier} by providing additional methods that
* allow write access to the contained object.
*
* @param
* the type of object the container can carry
*/
public interface WritableSupplier extends Supplier, Consumer
{
/**
* 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 #accept(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 accept(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