Package io.helidon.config
Class ConfigMappers
- java.lang.Object
-
- io.helidon.config.ConfigMappers
-
public final class ConfigMappers extends Object
Utility methods for converting configuration to Java types.Note that this class defines many methods of the form
<type> to<type>(String)
which are automatically registered with eachConfig.Builder
.- See Also:
ConfigMapperProvider
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static BigDecimal
toBigDecimal(String stringValue)
MapsstringValue
toBigDecimal
.static BigInteger
toBigInteger(String stringValue)
MapsstringValue
toBigInteger
.static Boolean
toBoolean(String stringValue)
MapsstringValue
toboolean
.static Byte
toByte(String stringValue)
MapsstringValue
tobyte
.static Calendar
toCalendar(String stringValue)
Deprecated.use new time API, such asZonedDateTime
static Character
toChar(String stringValue)
MapsstringValue
tochar
.static Charset
toCharset(String stringValue)
MapsstringValue
toCharset
.static Class<?>
toClass(String stringValue)
MapsstringValue
toClass<?>
.static Date
toDate(String stringValue)
Deprecated.Use one of the time API classes, such asInstant
orZonedDateTime
static Double
toDouble(String stringValue)
MapsstringValue
todouble
.static Duration
toDuration(String stringValue)
MapsstringValue
toDuration
.static File
toFile(String stringValue)
MapsstringValue
toFile
.static Float
toFloat(String stringValue)
MapsstringValue
tofloat
.static GregorianCalendar
toGregorianCalendar(String stringValue)
Deprecated.use new time API, such asZonedDateTime
static Instant
toInstant(String stringValue)
MapsstringValue
toInstant
.static Integer
toInt(String stringValue)
MapsstringValue
toint
.static LocalDate
toLocalDate(String stringValue)
MapsstringValue
toLocalDate
.static LocalDateTime
toLocalDateTime(String stringValue)
MapsstringValue
toLocalDateTime
.static LocalTime
toLocalTime(String stringValue)
MapsstringValue
toLocalTime
.static Long
toLong(String stringValue)
MapsstringValue
tolong
.static Map<String,String>
toMap(Config config)
Transform all leaf nodes (values) into Map instance.static OffsetDateTime
toOffsetDateTime(String stringValue)
MapsstringValue
toOffsetDateTime
.static OffsetTime
toOffsetTime(String stringValue)
MapsstringValue
toOffsetTime
.static Path
toPath(String stringValue)
MapsstringValue
toPath
.static Pattern
toPattern(String stringValue)
MapsstringValue
toPattern
.static Period
toPeriod(String stringValue)
MapsstringValue
toPeriod
.static Properties
toProperties(Config config)
Transform all leaf nodes (values) into Properties instance.static Short
toShort(String stringValue)
MapsstringValue
toshort
.static SimpleTimeZone
toSimpleTimeZone(String stringValue)
Deprecated.use new time API, such asZoneId
static TimeZone
toTimeZone(String stringValue)
Deprecated.use new time API, such asZoneId
static URI
toUri(String stringValue)
MapsstringValue
toURI
.static URL
toUrl(String stringValue)
MapsstringValue
toURL
.static UUID
toUUID(String stringValue)
MapsstringValue
toUUID
.static ZonedDateTime
toZonedDateTime(String stringValue)
MapsstringValue
toZonedDateTime
.static ZoneId
toZoneId(String stringValue)
MapsstringValue
toZoneId
.static ZoneOffset
toZoneOffset(String stringValue)
MapsstringValue
toZoneOffset
.
-
-
-
Method Detail
-
toByte
public static Byte toByte(String stringValue)
MapsstringValue
tobyte
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
tobyte
-
toShort
public static Short toShort(String stringValue)
MapsstringValue
toshort
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toshort
-
toInt
public static Integer toInt(String stringValue)
MapsstringValue
toint
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toint
-
toLong
public static Long toLong(String stringValue)
MapsstringValue
tolong
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
tolong
-
toFloat
public static Float toFloat(String stringValue)
MapsstringValue
tofloat
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
tofloat
-
toDouble
public static Double toDouble(String stringValue)
MapsstringValue
todouble
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
todouble
-
toBoolean
public static Boolean toBoolean(String stringValue)
MapsstringValue
toboolean
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toboolean
-
toChar
public static Character toChar(String stringValue)
MapsstringValue
tochar
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
tochar
-
toClass
public static Class<?> toClass(String stringValue)
MapsstringValue
toClass<?>
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toClass<?>
-
toUUID
public static UUID toUUID(String stringValue)
MapsstringValue
toUUID
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toUUID
-
toBigDecimal
public static BigDecimal toBigDecimal(String stringValue)
MapsstringValue
toBigDecimal
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toBigDecimal
-
toBigInteger
public static BigInteger toBigInteger(String stringValue)
MapsstringValue
toBigInteger
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toBigInteger
-
toFile
public static File toFile(String stringValue)
MapsstringValue
toFile
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toFile
-
toPath
public static Path toPath(String stringValue)
MapsstringValue
toPath
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toPath
-
toCharset
public static Charset toCharset(String stringValue)
MapsstringValue
toCharset
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toCharset
-
toPattern
public static Pattern toPattern(String stringValue)
MapsstringValue
toPattern
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toPattern
-
toUri
public static URI toUri(String stringValue)
MapsstringValue
toURI
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toURI
-
toUrl
public static URL toUrl(String stringValue)
MapsstringValue
toURL
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toURL
-
toDate
@Deprecated public static Date toDate(String stringValue)
Deprecated.Use one of the time API classes, such asInstant
orZonedDateTime
MapsstringValue
toDate
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toDate
- See Also:
DateTimeFormatter.ISO_DATE_TIME
-
toCalendar
@Deprecated public static Calendar toCalendar(String stringValue)
Deprecated.use new time API, such asZonedDateTime
MapsstringValue
toCalendar
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toCalendar
- See Also:
DateTimeFormatter.ISO_DATE_TIME
-
toGregorianCalendar
@Deprecated public static GregorianCalendar toGregorianCalendar(String stringValue)
Deprecated.use new time API, such asZonedDateTime
MapsstringValue
toGregorianCalendar
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toGregorianCalendar
- See Also:
DateTimeFormatter.ISO_DATE_TIME
-
toLocalDate
public static LocalDate toLocalDate(String stringValue)
MapsstringValue
toLocalDate
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toLocalDate
- See Also:
LocalDate.parse(CharSequence)
-
toLocalTime
public static LocalTime toLocalTime(String stringValue)
MapsstringValue
toLocalTime
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toLocalTime
- See Also:
LocalTime.parse(CharSequence)
-
toLocalDateTime
public static LocalDateTime toLocalDateTime(String stringValue)
MapsstringValue
toLocalDateTime
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toLocalDateTime
- See Also:
LocalDateTime.parse(CharSequence)
-
toZonedDateTime
public static ZonedDateTime toZonedDateTime(String stringValue)
MapsstringValue
toZonedDateTime
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toZonedDateTime
- See Also:
ZonedDateTime.parse(CharSequence)
-
toZoneId
public static ZoneId toZoneId(String stringValue)
MapsstringValue
toZoneId
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toZoneId
- See Also:
ZoneId.of(String)
-
toZoneOffset
public static ZoneOffset toZoneOffset(String stringValue)
MapsstringValue
toZoneOffset
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toZoneOffset
- See Also:
ZoneOffset.of(String)
-
toTimeZone
@Deprecated public static TimeZone toTimeZone(String stringValue)
Deprecated.use new time API, such asZoneId
MapsstringValue
toTimeZone
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toTimeZone
- See Also:
ZoneId.of(String)
-
toSimpleTimeZone
@Deprecated public static SimpleTimeZone toSimpleTimeZone(String stringValue)
Deprecated.use new time API, such asZoneId
MapsstringValue
toSimpleTimeZone
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toSimpleTimeZone
- See Also:
ZoneId.of(String)
-
toInstant
public static Instant toInstant(String stringValue)
MapsstringValue
toInstant
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toInstant
- See Also:
Instant.parse(CharSequence)
-
toOffsetDateTime
public static OffsetDateTime toOffsetDateTime(String stringValue)
MapsstringValue
toOffsetDateTime
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toOffsetDateTime
- See Also:
OffsetDateTime.parse(CharSequence)
-
toOffsetTime
public static OffsetTime toOffsetTime(String stringValue)
MapsstringValue
toOffsetTime
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toOffsetTime
- See Also:
OffsetTime.parse(CharSequence)
-
toDuration
public static Duration toDuration(String stringValue)
MapsstringValue
toDuration
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toDuration
- See Also:
Duration.parse(CharSequence)
-
toPeriod
public static Period toPeriod(String stringValue)
MapsstringValue
toPeriod
.- Parameters:
stringValue
- source value as aString
- Returns:
- mapped
stringValue
toPeriod
- See Also:
Period.parse(CharSequence)
-
toMap
public static Map<String,String> toMap(Config config)
Transform all leaf nodes (values) into Map instance.Fully qualified key of config node is used as a key in returned Map.
Detach
config node before transforming to Map in case you want to cut current Config node key prefix.Let's say we work with following configuration:
app: name: Example 1 page-size: 20 logging: app.level = INFO level = WARNING
Mapapp1
contains two keys:app.name
,app.page-size
.Map<String, String> app1 = ConfigMappers.toMap(config.get("app"));
Detaching
app
config node returns new Config instance with "reset" local root.
MapMap<String, String> app2 = ConfigMappers.toMap(config.get("app").detach());
app2
contains two keys withoutapp
prefix:name
,page-size
.- Parameters:
config
- config node used to transform into Properties- Returns:
- new Map instance that contains all config leaf node values
- See Also:
Config.detach()
-
toProperties
public static Properties toProperties(Config config)
Transform all leaf nodes (values) into Properties instance.Fully qualified key of config node is used as a key in returned Properties.
Detach
config node before transforming to Properties in case you want to cut current Config node key prefix.Let's say we work with following configuration:
app: name: Example 1 page-size: 20 logging: app.level = INFO level = WARNING
Propertiesapp1
contains two keys:app.name
,app.page-size
.Properties app1 = ConfigMappers.toProperties(config.get("app"));
Detaching
app
config node returns new Config instance with "reset" local root.Properties app2 = ConfigMappers.toProperties(config.get("app").detach());
Propertiesapp2
contains two keys withoutapp
prefix:name
,page-size
.- Parameters:
config
- config node used to transform into Properties- Returns:
- Properties instance that contains all config leaf node values.
- See Also:
Config.detach()
-
-