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

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;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy