Top Description Fields Methods
org.osgi.util.converter

public Interface ConverterFunction

Annotations
@ConsumerType
Imports
java.lang.reflect.Type, org.osgi.annotation.versioning.ConsumerType

An 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.

Author
$Id: 753819645ba2b4ea93b68cf467206fd23dd9da6d $

Field Summary

Modifier and TypeField and Description
public static final Object
CANNOT_HANDLE

Special object to indicate that a custom converter rule or error handler cannot handle the conversion.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

The conversion result or CANNOT_HANDLE to 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.
apply
(Object
The object to be converted. This object will never be null as the convert function will not be invoked for null values.
obj
,
Type
The target type.
targetType
)

Convert the object into the target type.

Field Detail

CANNOT_HANDLEback to summary
public static final Object CANNOT_HANDLE

Special object to indicate that a custom converter rule or error handler cannot handle the conversion.

Method Detail

applyback to summary
public Object apply(Object obj, Type targetType) throws Exception

Convert the object into the target type.

Parameters
obj:Object

The object to be converted. This object will never be null as the convert function will not be invoked for null values.

targetType:Type

The target type.

Returns:Object

The conversion result or CANNOT_HANDLE to 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.

Exceptions
Exception:
the operation can throw an exception if the conversion can not be performed due to incompatible types.