Interface ValueConverter<F,T>
- All Known Implementing Classes:
AbstractValueConverter, FromStringValueConverter
public interface ValueConverter<F,T>
Contract for converting objects from one type to another.
For example, you might have a ValueConverter<String, List<Integer>> which converts
text like "1,2,3" to a list of numbers.
Generic type inference only supports direct AbstractValueConverter / FromStringValueConverter
subclasses or direct ValueConverter implementations. If you introduce intermediate generic base classes
or type variables (for example, abstract class BadConverter<T> extends AbstractValueConverter<String, T> then
class JwtConverter extends BadConverter<Jwt>), Soklet may be unable to resolve F/T and will
throw an IllegalStateException. This limitation may be addressed in a future release.
Value conversion is documented in detail at https://www.soklet.com/docs/value-conversions.
- Author:
- Mark Allen
-
Method Summary
-
Method Details
-
convert
Convertsfromto an instance ofT.- Parameters:
from- the value from which to convert. May benull- Returns:
- the
Trepresentation offrom - Throws:
ValueConversionException- if an error occurs during conversion
-
getFromType
-
getToType
-