Top Description Methods
org.osgi.util.converter

public Interface Converting

extends Specifying<Converting>
Known Direct Subinterfaces
org.osgi.util.converter.InternalConverting
Known Direct Implementers
org.osgi.util.converter.ConvertingImpl
Annotations
@ProviderType
Imports
java.lang.reflect.Type, org.osgi.annotation.versioning.ProviderType

This interface is used to specify the target that an object should be converted to. A Converting instance can be obtained via the Converter.
Author
$Id: a0b7838a0ab2224c01c838b31a45fa8bd13d04e1 $

Method Summary

Modifier and TypeMethod and Description
public <
The type to convert to.
T
>
T

Returns:

The converted object.
to
(Class<T>
The class to convert to.
cls
)

Specify the target object type for the conversion as a class object.

public <
The type to convert to.
T
>
T

Returns:

The converted object.
to
(Type
A Type object to represent the target type to be converted to.
type
)

Specify the target object type as a Java Reflection Type object.

public <
The type to convert to.
T
>
T

Returns:

The converted object.
to
(TypeReference<T>
A type reference to the object being converted to.
ref
)

Specify the target object type as a TypeReference.

Inherited from org.osgi.util.converter.Specifying:
defaultValuekeysIgnoreCasesourceAssourceAsBeansourceAsDTOtargetAstargetAsBeantargetAsDTOview

Method Detail

toback to summary
public <T> T to(Class<T> cls)

Specify the target object type for the conversion as a class object.

Parameters
<T>
The type to convert to.
cls:Class<T>

The class to convert to.

Returns:T

The converted object.

toback to summary
public <T> T to(Type type)

Specify the target object type as a Java Reflection Type object.

Parameters
<T>
The type to convert to.
type:Type

A Type object to represent the target type to be converted to.

Returns:T

The converted object.

toback to summary
public <T> T to(TypeReference<T> ref)

Specify the target object type as a TypeReference. If the target class carries generics information a TypeReference should be used as this preserves the generic information whereas a Class object has this information erased. Example use:

List<String> result = converter.convert(Arrays.asList(1, 2, 3))
		.to(new TypeReference<List<String>>() {
		});
Parameters
<T>
The type to convert to.
ref:TypeReference<T>

A type reference to the object being converted to.

Returns:T

The converted object.