org.nasdanika.common.Converter Maven / Gradle / Ivy
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;
}
};
}
}