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

org.nasdanika.common.Converter Maven / Gradle / Ivy

There is a newer version: 2024.11.0
Show newest version
package org.nasdanika.common;

/**
 * Converts object to target type.
 * @author Pavel
 *
 * @param  Source type
 * @param  Target type
 * @param  Context type
 */
public interface Converter extends Composable {
	
	 T convert(Object source, Class type);
	
	default Converter compose(Converter other) {
		if (other == null) {
			return this;
		}
		
		return new Converter() {
			
			@Override
			public  T convert(Object source, Class type) {
				T ret = Converter.this.convert(source, type);
				return ret == null ? other.convert(source, type) : ret;
			}
		};
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy