org.codefilarete.tool.function.Hanger Maven / Gradle / Ivy
package org.codefilarete.tool.function;
import java.util.function.Supplier;
/**
* A simple interface to define that you can hang something on it, opposit to {@link Supplier}
*
* @author Guillaume Mary
*/
@FunctionalInterface
public interface Hanger {
void set(T value);
/**
* A {@link Hanger} and {@link Supplier}
*
* @param
*/
class Holder implements Hanger, Supplier {
private T payload;
public Holder() {
}
public Holder(T payload) {
this.payload = payload;
}
@Override
public void set(T value) {
this.payload = value;
}
@Override
public T get() {
return payload;
}
}
}