Interface Converter<T>
Interface for converting configured values from String to any Java type.
Converters for the following types are provided by default:
boolean
andBoolean
, values fortrue
: (case insensitive) "true", "yes", "Y", "on", "1"int
andInteger
long
andLong
float
andFloat
, a dot '.' is used to separate the fractional digitsdouble
andDouble
, a dot '.' is used to separate the fractional digitsjava.time.Duration
as defined inDuration.parse(CharSequence)
java.time.LocalDateTime
as defined inLocalDateTime.parse(CharSequence)
java.time.LocalDate
as defined inLocalDate.parse(CharSequence)
java.time.LocalTime
as defined inLocalTime.parse(CharSequence)
OffsetDateTime
as defined inOffsetDateTime.parse(CharSequence)
OffsetTime
as defined inOffsetTime.parse(CharSequence)
Instant
URL
as defined byURL(java.lang.String)
Custom Converters will get picked up via the ServiceLoader
mechanism and and can be registered by
providing a file
META-INF/services/org.eclipse.microprofile.config.spi.Converter
which contains the fully qualified Converter
implementation class name as content.
A Converter can specify a javax.annotation.Priority
.
If no priority is explicitly assigned, the value of 100 is assumed.
If multiple Converters are registered for the same type, the one with the highest priority will be used.
All Built In Converters have a javax.annotation.Priority
of 1
A Converter should handle null values returning either null or a valid Object of the specified type.
-
Method Summary
-
Method Details
-
convert
Configure the string value to a specified type- Parameters:
value
- the string representation of a property value.- Returns:
- the converted value or null
- Throws:
IllegalArgumentException
- if the value cannot be converted to the specified type.
-