org.codefilarete.tool.function.Converter Maven / Gradle / Ivy
package org.codefilarete.tool.function;
/**
* @author Guillaume Mary
*/
@FunctionalInterface
public interface Converter extends ThrowingConverter {
abstract class NullAwareConverter implements Converter {
@Override
public O convert(I input) {
return input == null ? convertNull() : convertNotNull(input);
}
/**
* Called for returning a value when input is null.
* This implementation returns null
*
* @return whatever needed
*/
protected O convertNull() {
return null;
}
protected abstract O convertNotNull(I input);
}
}