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 BigDecimaltoBigDecimal(String stringValue)MapsstringValuetoBigDecimal.static BigIntegertoBigInteger(String stringValue)MapsstringValuetoBigInteger.static BooleantoBoolean(String stringValue)MapsstringValuetoboolean.static BytetoByte(String stringValue)MapsstringValuetobyte.static CalendartoCalendar(String stringValue)Deprecated.use new time API, such asZonedDateTimestatic CharactertoChar(String stringValue)MapsstringValuetochar.static CharsettoCharset(String stringValue)MapsstringValuetoCharset.static Class<?>toClass(String stringValue)MapsstringValuetoClass<?>.static DatetoDate(String stringValue)Deprecated.Use one of the time API classes, such asInstantorZonedDateTimestatic DoubletoDouble(String stringValue)MapsstringValuetodouble.static DurationtoDuration(String stringValue)MapsstringValuetoDuration.static FiletoFile(String stringValue)MapsstringValuetoFile.static FloattoFloat(String stringValue)MapsstringValuetofloat.static GregorianCalendartoGregorianCalendar(String stringValue)Deprecated.use new time API, such asZonedDateTimestatic InstanttoInstant(String stringValue)MapsstringValuetoInstant.static IntegertoInt(String stringValue)MapsstringValuetoint.static LocalDatetoLocalDate(String stringValue)MapsstringValuetoLocalDate.static LocalDateTimetoLocalDateTime(String stringValue)MapsstringValuetoLocalDateTime.static LocalTimetoLocalTime(String stringValue)MapsstringValuetoLocalTime.static LongtoLong(String stringValue)MapsstringValuetolong.static Map<String,String>toMap(Config config)Transform all leaf nodes (values) into Map instance.static OffsetDateTimetoOffsetDateTime(String stringValue)MapsstringValuetoOffsetDateTime.static OffsetTimetoOffsetTime(String stringValue)MapsstringValuetoOffsetTime.static PathtoPath(String stringValue)MapsstringValuetoPath.static PatterntoPattern(String stringValue)MapsstringValuetoPattern.static PeriodtoPeriod(String stringValue)MapsstringValuetoPeriod.static PropertiestoProperties(Config config)Transform all leaf nodes (values) into Properties instance.static ShorttoShort(String stringValue)MapsstringValuetoshort.static SimpleTimeZonetoSimpleTimeZone(String stringValue)Deprecated.use new time API, such asZoneIdstatic TimeZonetoTimeZone(String stringValue)Deprecated.use new time API, such asZoneIdstatic URItoUri(String stringValue)MapsstringValuetoURI.static URLtoUrl(String stringValue)MapsstringValuetoURL.static UUIDtoUUID(String stringValue)MapsstringValuetoUUID.static ZonedDateTimetoZonedDateTime(String stringValue)MapsstringValuetoZonedDateTime.static ZoneIdtoZoneId(String stringValue)MapsstringValuetoZoneId.static ZoneOffsettoZoneOffset(String stringValue)MapsstringValuetoZoneOffset.
-
-
-
Method Detail
-
toByte
public static Byte toByte(String stringValue)
MapsstringValuetobyte.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetobyte
-
toShort
public static Short toShort(String stringValue)
MapsstringValuetoshort.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoshort
-
toInt
public static Integer toInt(String stringValue)
MapsstringValuetoint.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoint
-
toLong
public static Long toLong(String stringValue)
MapsstringValuetolong.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetolong
-
toFloat
public static Float toFloat(String stringValue)
MapsstringValuetofloat.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetofloat
-
toDouble
public static Double toDouble(String stringValue)
MapsstringValuetodouble.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetodouble
-
toBoolean
public static Boolean toBoolean(String stringValue)
MapsstringValuetoboolean.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoboolean
-
toChar
public static Character toChar(String stringValue)
MapsstringValuetochar.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetochar
-
toClass
public static Class<?> toClass(String stringValue)
MapsstringValuetoClass<?>.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoClass<?>
-
toUUID
public static UUID toUUID(String stringValue)
MapsstringValuetoUUID.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoUUID
-
toBigDecimal
public static BigDecimal toBigDecimal(String stringValue)
MapsstringValuetoBigDecimal.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoBigDecimal
-
toBigInteger
public static BigInteger toBigInteger(String stringValue)
MapsstringValuetoBigInteger.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoBigInteger
-
toFile
public static File toFile(String stringValue)
MapsstringValuetoFile.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoFile
-
toPath
public static Path toPath(String stringValue)
MapsstringValuetoPath.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoPath
-
toCharset
public static Charset toCharset(String stringValue)
MapsstringValuetoCharset.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoCharset
-
toPattern
public static Pattern toPattern(String stringValue)
MapsstringValuetoPattern.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoPattern
-
toUri
public static URI toUri(String stringValue)
MapsstringValuetoURI.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoURI
-
toUrl
public static URL toUrl(String stringValue)
MapsstringValuetoURL.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoURL
-
toDate
@Deprecated public static Date toDate(String stringValue)
Deprecated.Use one of the time API classes, such asInstantorZonedDateTimeMapsstringValuetoDate.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoDate - See Also:
DateTimeFormatter.ISO_DATE_TIME
-
toCalendar
@Deprecated public static Calendar toCalendar(String stringValue)
Deprecated.use new time API, such asZonedDateTimeMapsstringValuetoCalendar.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoCalendar - See Also:
DateTimeFormatter.ISO_DATE_TIME
-
toGregorianCalendar
@Deprecated public static GregorianCalendar toGregorianCalendar(String stringValue)
Deprecated.use new time API, such asZonedDateTimeMapsstringValuetoGregorianCalendar.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoGregorianCalendar - See Also:
DateTimeFormatter.ISO_DATE_TIME
-
toLocalDate
public static LocalDate toLocalDate(String stringValue)
MapsstringValuetoLocalDate.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoLocalDate - See Also:
LocalDate.parse(CharSequence)
-
toLocalTime
public static LocalTime toLocalTime(String stringValue)
MapsstringValuetoLocalTime.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoLocalTime - See Also:
LocalTime.parse(CharSequence)
-
toLocalDateTime
public static LocalDateTime toLocalDateTime(String stringValue)
MapsstringValuetoLocalDateTime.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoLocalDateTime - See Also:
LocalDateTime.parse(CharSequence)
-
toZonedDateTime
public static ZonedDateTime toZonedDateTime(String stringValue)
MapsstringValuetoZonedDateTime.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoZonedDateTime - See Also:
ZonedDateTime.parse(CharSequence)
-
toZoneId
public static ZoneId toZoneId(String stringValue)
MapsstringValuetoZoneId.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoZoneId - See Also:
ZoneId.of(String)
-
toZoneOffset
public static ZoneOffset toZoneOffset(String stringValue)
MapsstringValuetoZoneOffset.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoZoneOffset - See Also:
ZoneOffset.of(String)
-
toTimeZone
@Deprecated public static TimeZone toTimeZone(String stringValue)
Deprecated.use new time API, such asZoneIdMapsstringValuetoTimeZone.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoTimeZone - See Also:
ZoneId.of(String)
-
toSimpleTimeZone
@Deprecated public static SimpleTimeZone toSimpleTimeZone(String stringValue)
Deprecated.use new time API, such asZoneIdMapsstringValuetoSimpleTimeZone.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoSimpleTimeZone - See Also:
ZoneId.of(String)
-
toInstant
public static Instant toInstant(String stringValue)
MapsstringValuetoInstant.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoInstant - See Also:
Instant.parse(CharSequence)
-
toOffsetDateTime
public static OffsetDateTime toOffsetDateTime(String stringValue)
MapsstringValuetoOffsetDateTime.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoOffsetDateTime - See Also:
OffsetDateTime.parse(CharSequence)
-
toOffsetTime
public static OffsetTime toOffsetTime(String stringValue)
MapsstringValuetoOffsetTime.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoOffsetTime - See Also:
OffsetTime.parse(CharSequence)
-
toDuration
public static Duration toDuration(String stringValue)
MapsstringValuetoDuration.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoDuration - See Also:
Duration.parse(CharSequence)
-
toPeriod
public static Period toPeriod(String stringValue)
MapsstringValuetoPeriod.- Parameters:
stringValue- source value as aString- Returns:
- mapped
stringValuetoPeriod - 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.
Detachconfig 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 = WARNINGMapapp1contains two keys:app.name,app.page-size.Map<String, String> app1 = ConfigMappers.toMap(config.get("app"));Detachingappconfig node returns new Config instance with "reset" local root.
MapMap<String, String> app2 = ConfigMappers.toMap(config.get("app").detach());app2contains two keys withoutappprefix: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.
Detachconfig 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 = WARNINGPropertiesapp1contains two keys:app.name,app.page-size.Properties app1 = ConfigMappers.toProperties(config.get("app"));Detachingappconfig node returns new Config instance with "reset" local root.Properties app2 = ConfigMappers.toProperties(config.get("app").detach());Propertiesapp2contains two keys withoutappprefix: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()
-
-