Interface IConverter<F,T>
-
- Type Parameters:
F
- type of the source valueT
- type of the converted value
- All Known Implementing Classes:
org.eclipse.core.internal.databinding.conversion.AbstractNumberToStringConverter
,org.eclipse.core.internal.databinding.conversion.AbstractStringToNumberConverter
,Converter
,org.eclipse.core.internal.databinding.validation.NumberFormatConverter
,NumberToStringConverter
,StringToNumberConverter
public interface IConverter<F,T>
A one-way converter.- Since:
- 1.0
- Restriction:
- This interface is not intended to be implemented by clients.
Clients should subclass
Converter
. - Restriction:
- This interface is not intended to be extended by clients.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description T
convert(F fromObject)
Returns the result of the conversion of the given object.static <F,T>
IConverter<F,T>create(Object fromType, Object toType, Function<F,T> conversion)
Creates a converter which calls the argument conversion function.static <F,T>
IConverter<F,T>create(Function<F,T> conversion)
Creates an untyped converter which calls the argument conversion function.Object
getFromType()
Returns the type whose instances can be converted by this converter.Object
getToType()
Returns the type to which this converter can convert.
-
-
-
Method Detail
-
getFromType
Object getFromType()
Returns the type whose instances can be converted by this converter. The return type is Object rather than Class to optionally support richer type systems than the one provided by Java reflection.- Returns:
- the type whose instances can be converted, or null if this converter is untyped
-
getToType
Object getToType()
Returns the type to which this converter can convert. The return type is Object rather than Class to optionally support richer type systems than the one provided by Java reflection.- Returns:
- the type to which this converter can convert, or null if this converter is untyped
-
convert
T convert(F fromObject)
Returns the result of the conversion of the given object.- Parameters:
fromObject
- the object to convert, of typegetFromType()
- Returns:
- the converted object, of type
getToType()
-
create
static <F,T> IConverter<F,T> create(Object fromType, Object toType, Function<F,T> conversion)
Creates a converter which calls the argument conversion function.- Parameters:
fromType
- the from typetoType
- the to typeconversion
- the conversion function- Returns:
- the new converter
- Since:
- 1.6
-
create
static <F,T> IConverter<F,T> create(Function<F,T> conversion)
Creates an untyped converter which calls the argument conversion function. null is used as the to and from types.- Parameters:
conversion
- the conversion function- Returns:
- the new converter
- Since:
- 1.8
-
-