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

org.bbottema.javareflection.util.Function Maven / Gradle / Ivy

package org.bbottema.javareflection.util;

import static org.bbottema.javareflection.util.MiscUtil.trustedCast;

public interface Function {
	T apply(F value);
	
	class Functions {
		
		private static final Function IDENTITY_FUNCTION = new Function() {
			@Override
			public Object apply(Object value) {
				return value;
			}
		};
		
		private static final Function TOSTRING_FUNCTION = new Function() {
			@Override
			public String apply(Object value) {
				return value.toString();
			}
		};
		
		public static  Function identity() {
			return trustedCast(IDENTITY_FUNCTION);
		}
		
		public static  Function simpleToString() {
			return trustedCast(TOSTRING_FUNCTION);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy