Package org.osgi.util.converter
Interface ConverterFunction
-
@ConsumerType public interface ConverterFunctionAn functional interface with a convert method that is passed the original object and the target type to perform a custom conversion.This interface can also be used to register a custom error handler.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.ObjectCANNOT_HANDLESpecial object to indicate that a custom converter rule or error handler cannot handle the conversion.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Objectapply(java.lang.Object obj, java.lang.reflect.Type targetType)Convert the object into the target type.
-
-
-
Method Detail
-
apply
java.lang.Object apply(java.lang.Object obj, java.lang.reflect.Type targetType) throws java.lang.ExceptionConvert the object into the target type.- Parameters:
obj- The object to be converted. This object will never benullas the convert function will not be invoked for null values.targetType- The target type.- Returns:
- The conversion result or
CANNOT_HANDLEto indicate that the convert function cannot handle this conversion. In this case the next matching rule or parent converter will be given a opportunity to convert. - Throws:
java.lang.Exception- the operation can throw an exception if the conversion can not be performed due to incompatible types.
-
-