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

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

Go to download

Java Reflection provides a small package with nifty reflection features that will help with finding constructors, methods and value conversions

There is a newer version: 4.1.0
Show newest version
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