chaschev.lang.MutableSupplier Maven / Gradle / Ivy
package chaschev.lang;
import com.google.common.base.Supplier;
/**
* @author Andrey Chaschev [email protected]
*/
public class MutableSupplier implements Supplier {
T instance;
boolean finalized;
public MutableSupplier(T instance) {
this.instance = instance;
}
public MutableSupplier() {
}
@Override
public T get() {
return instance;
}
public boolean isFinalized(){
return finalized;
}
public MutableSupplier setInstance(T instance) {
if(!finalized){
this.instance = instance;
}else{
throw new IllegalStateException("can't change, already finalized");
}
return this;
}
public MutableSupplier makeFinal(){
finalized = true;
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy