Package org.osgi.util.converter
Class CustomConverterImpl.ConvertingWrapper
java.lang.Object
org.osgi.util.converter.CustomConverterImpl.ConvertingWrapper
- All Implemented Interfaces:
Converting
,InternalConverting
,Specifying<Converting>
- Enclosing class:
CustomConverterImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Object
private final InternalConverting
private boolean
private final Object
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondefaultValue
(Object defVal) The default value to use when the object cannot be converted or in case of conversion from anull
value.When converting between map-like types use case-insensitive mapping of keys.void
Set the current converter.Treat the source object as the specified class.Treat the source object as a JavaBean.Treat the source object as a DTO even if the source object has methods or is otherwise not recognized as a DTO.Treat the target object as the specified class.Treat the target object as a JavaBean.Treat the target object as a DTO even if it has methods or is otherwise not recognized as a DTO.<T> T
Specify the target object type for the conversion as a class object.<T> T
Specify the target object type as a Java Reflection Type object.<T> T
to
(TypeReference<T> ref) Specify the target object type as aTypeReference
.toString()
view()
Return a live view over the backing object that reflects any changes to the original object.
-
Field Details
-
del
-
object
-
defaultValue
-
hasDefault
private volatile boolean hasDefault
-
-
Constructor Details
-
ConvertingWrapper
ConvertingWrapper(Object obj, InternalConverting c)
-
-
Method Details
-
view
Description copied from interface:Specifying
Return a live view over the backing object that reflects any changes to the original object. This is only possible with conversions toMap
,Collection
,List
andSet
. The live view object will cease to be live as soon as modifications are made to it. Note that conversions to an interface or annotation will always produce a live view that cannot be modified. This modifier has no effect with conversions to other types.- Specified by:
view
in interfaceSpecifying<Converting>
- Returns:
- The current
Converting
object so that additional calls can be chained.
-
defaultValue
Description copied from interface:Specifying
The default value to use when the object cannot be converted or in case of conversion from anull
value.- Specified by:
defaultValue
in interfaceSpecifying<Converting>
- Parameters:
defVal
- The default value.- Returns:
- The current
Converting
object so that additional calls can be chained.
-
keysIgnoreCase
Description copied from interface:Specifying
When converting between map-like types use case-insensitive mapping of keys.- Specified by:
keysIgnoreCase
in interfaceSpecifying<Converting>
- Returns:
- The current
Converting
object so that additional calls can be chained.
-
setConverter
Description copied from interface:InternalConverting
Set the current converter.- Specified by:
setConverter
in interfaceInternalConverting
- Parameters:
c
- The current converter.
-
sourceAs
Description copied from interface:Specifying
Treat the source object as the specified class. This can be used to disambiguate a type if it implements multiple interfaces or extends multiple classes.- Specified by:
sourceAs
in interfaceSpecifying<Converting>
- Parameters:
type
- The class to treat the object as.- Returns:
- The current
Converting
object so that additional calls can be chained.
-
sourceAsBean
Description copied from interface:Specifying
Treat the source object as a JavaBean. By default objects will not be treated as JavaBeans, this has to be specified using this method.- Specified by:
sourceAsBean
in interfaceSpecifying<Converting>
- Returns:
- The current
Converting
object so that additional calls can be chained.
-
sourceAsDTO
Description copied from interface:Specifying
Treat the source object as a DTO even if the source object has methods or is otherwise not recognized as a DTO.- Specified by:
sourceAsDTO
in interfaceSpecifying<Converting>
- Returns:
- The current
Converting
object so that additional calls can be chained.
-
targetAs
Description copied from interface:Specifying
Treat the target object as the specified class. This can be used to disambiguate a type if it implements multiple interfaces or extends multiple classes.- Specified by:
targetAs
in interfaceSpecifying<Converting>
- Parameters:
cls
- The class to treat the object as.- Returns:
- The current
Converting
object so that additional calls can be chained.
-
targetAsBean
Description copied from interface:Specifying
Treat the target object as a JavaBean. By default objects will not be treated as JavaBeans, this has to be specified using this method.- Specified by:
targetAsBean
in interfaceSpecifying<Converting>
- Returns:
- The current
Converting
object so that additional calls can be chained.
-
targetAsDTO
Description copied from interface:Specifying
Treat the target object as a DTO even if it has methods or is otherwise not recognized as a DTO.- Specified by:
targetAsDTO
in interfaceSpecifying<Converting>
- Returns:
- The current
Converting
object so that additional calls can be chained.
-
to
Description copied from interface:Converting
Specify the target object type for the conversion as a class object.- Specified by:
to
in interfaceConverting
- Parameters:
cls
- The class to convert to.- Returns:
- The converted object.
-
to
Description copied from interface:Converting
Specify the target object type as aTypeReference
. 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>>() {});
- Specified by:
to
in interfaceConverting
- Parameters:
ref
- A type reference to the object being converted to.- Returns:
- The converted object.
-
to
Description copied from interface:Converting
Specify the target object type as a Java Reflection Type object.- Specified by:
to
in interfaceConverting
- Parameters:
type
- A Type object to represent the target type to be converted to.- Returns:
- The converted object.
-
toString
-