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
private class CustomConverterImpl.ConvertingWrapper extends java.lang.Object implements InternalConverting
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ObjectdefaultValueprivate InternalConvertingdelprivate booleanhasDefaultprivate java.lang.Objectobject
-
Constructor Summary
Constructors Constructor Description ConvertingWrapper(java.lang.Object obj, InternalConverting c)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConvertingdefaultValue(java.lang.Object defVal)The default value to use when the object cannot be converted or in case of conversion from anullvalue.ConvertingkeysIgnoreCase()When converting between map-like types use case-insensitive mapping of keys.voidsetConverter(Converter c)Set the current converter.ConvertingsourceAs(java.lang.Class<?> type)Treat the source object as the specified class.ConvertingsourceAsBean()Treat the source object as a JavaBean.ConvertingsourceAsDTO()Treat the source object as a DTO even if the source object has methods or is otherwise not recognized as a DTO.ConvertingtargetAs(java.lang.Class<?> cls)Treat the target object as the specified class.ConvertingtargetAsBean()Treat the target object as a JavaBean.ConvertingtargetAsDTO()Treat the target object as a DTO even if it has methods or is otherwise not recognized as a DTO.<T> Tto(java.lang.Class<T> cls)Specify the target object type for the conversion as a class object.<T> Tto(java.lang.reflect.Type type)Specify the target object type as a Java Reflection Type object.<T> Tto(TypeReference<T> ref)Specify the target object type as aTypeReference.java.lang.StringtoString()Convertingview()Return a live view over the backing object that reflects any changes to the original object.
-
-
-
Field Detail
-
del
private final InternalConverting del
-
object
private final java.lang.Object object
-
defaultValue
private volatile java.lang.Object defaultValue
-
hasDefault
private volatile boolean hasDefault
-
-
Constructor Detail
-
ConvertingWrapper
ConvertingWrapper(java.lang.Object obj, InternalConverting c)
-
-
Method Detail
-
view
public Converting view()
Description copied from interface:SpecifyingReturn a live view over the backing object that reflects any changes to the original object. This is only possible with conversions toMap,Collection,ListandSet. 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:
viewin interfaceSpecifying<Converting>- Returns:
- The current
Convertingobject so that additional calls can be chained.
-
defaultValue
public Converting defaultValue(java.lang.Object defVal)
Description copied from interface:SpecifyingThe default value to use when the object cannot be converted or in case of conversion from anullvalue.- Specified by:
defaultValuein interfaceSpecifying<Converting>- Parameters:
defVal- The default value.- Returns:
- The current
Convertingobject so that additional calls can be chained.
-
keysIgnoreCase
public Converting keysIgnoreCase()
Description copied from interface:SpecifyingWhen converting between map-like types use case-insensitive mapping of keys.- Specified by:
keysIgnoreCasein interfaceSpecifying<Converting>- Returns:
- The current
Convertingobject so that additional calls can be chained.
-
setConverter
public void setConverter(Converter c)
Description copied from interface:InternalConvertingSet the current converter.- Specified by:
setConverterin interfaceInternalConverting- Parameters:
c- The current converter.
-
sourceAs
public Converting sourceAs(java.lang.Class<?> type)
Description copied from interface:SpecifyingTreat 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:
sourceAsin interfaceSpecifying<Converting>- Parameters:
type- The class to treat the object as.- Returns:
- The current
Convertingobject so that additional calls can be chained.
-
sourceAsBean
public Converting sourceAsBean()
Description copied from interface:SpecifyingTreat 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:
sourceAsBeanin interfaceSpecifying<Converting>- Returns:
- The current
Convertingobject so that additional calls can be chained.
-
sourceAsDTO
public Converting sourceAsDTO()
Description copied from interface:SpecifyingTreat the source object as a DTO even if the source object has methods or is otherwise not recognized as a DTO.- Specified by:
sourceAsDTOin interfaceSpecifying<Converting>- Returns:
- The current
Convertingobject so that additional calls can be chained.
-
targetAs
public Converting targetAs(java.lang.Class<?> cls)
Description copied from interface:SpecifyingTreat 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:
targetAsin interfaceSpecifying<Converting>- Parameters:
cls- The class to treat the object as.- Returns:
- The current
Convertingobject so that additional calls can be chained.
-
targetAsBean
public Converting targetAsBean()
Description copied from interface:SpecifyingTreat 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:
targetAsBeanin interfaceSpecifying<Converting>- Returns:
- The current
Convertingobject so that additional calls can be chained.
-
targetAsDTO
public Converting targetAsDTO()
Description copied from interface:SpecifyingTreat the target object as a DTO even if it has methods or is otherwise not recognized as a DTO.- Specified by:
targetAsDTOin interfaceSpecifying<Converting>- Returns:
- The current
Convertingobject so that additional calls can be chained.
-
to
public <T> T to(java.lang.Class<T> cls)
Description copied from interface:ConvertingSpecify the target object type for the conversion as a class object.- Specified by:
toin interfaceConverting- Parameters:
cls- The class to convert to.- Returns:
- The converted object.
-
to
public <T> T to(TypeReference<T> ref)
Description copied from interface:ConvertingSpecify 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:
toin interfaceConverting- Parameters:
ref- A type reference to the object being converted to.- Returns:
- The converted object.
-
to
public <T> T to(java.lang.reflect.Type type)
Description copied from interface:ConvertingSpecify the target object type as a Java Reflection Type object.- Specified by:
toin interfaceConverting- Parameters:
type- A Type object to represent the target type to be converted to.- Returns:
- The converted object.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-