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

xy.reflect.ui.util.Accessor Maven / Gradle / Ivy

package xy.reflect.ui.util;

public abstract class Accessor {
	public abstract T get();

	public void set(T t) {
		throw new UnsupportedOperationException();
	}
	
	public static  Accessor returning(final T t) {
		return returning(t, true);
	}
		

	public static  Accessor returning(final T t, final boolean canSet) {
		return new Accessor() {
			
			T value = t;
			
			@Override
			public T get() {
				return value;
			}

			@Override
			public void set(T t) {
				if (canSet) {
					value = t;
				}else{
					throw new UnsupportedOperationException();
				}
			}

		};
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy