public final class ConfigMappers extends Object
Note that this class defines many methods of the form <type> to<type>(String)
which are automatically registered with each Config.Builder.
ConfigMapperProvider| Modifier and Type | Method and Description |
|---|---|
static BigDecimal |
toBigDecimal(String stringValue)
Maps
stringValue to BigDecimal. |
static BigInteger |
toBigInteger(String stringValue)
Maps
stringValue to BigInteger. |
static Boolean |
toBoolean(String stringValue)
Maps
stringValue to boolean. |
static Byte |
toByte(String stringValue)
Maps
stringValue to byte. |
static Calendar |
toCalendar(String stringValue)
Deprecated.
use new time API, such as
ZonedDateTime |
static Character |
toChar(String stringValue)
Maps
stringValue to char. |
static Charset |
toCharset(String stringValue)
Maps
stringValue to Charset. |
static Class<?> |
toClass(String stringValue)
Maps
stringValue to Class<?>. |
static Date |
toDate(String stringValue)
Deprecated.
Use one of the time API classes, such as
Instant or ZonedDateTime |
static Double |
toDouble(String stringValue)
Maps
stringValue to double. |
static Duration |
toDuration(String stringValue)
Maps
stringValue to Duration. |
static File |
toFile(String stringValue)
Maps
stringValue to File. |
static Float |
toFloat(String stringValue)
Maps
stringValue to float. |
static GregorianCalendar |
toGregorianCalendar(String stringValue)
Deprecated.
use new time API, such as
ZonedDateTime |
static Instant |
toInstant(String stringValue)
Maps
stringValue to Instant. |
static Integer |
toInt(String stringValue)
Maps
stringValue to int. |
static LocalDate |
toLocalDate(String stringValue)
Maps
stringValue to LocalDate. |
static LocalDateTime |
toLocalDateTime(String stringValue)
Maps
stringValue to LocalDateTime. |
static LocalTime |
toLocalTime(String stringValue)
Maps
stringValue to LocalTime. |
static Long |
toLong(String stringValue)
Maps
stringValue to long. |
static Map<String,String> |
toMap(Config config)
Transform all leaf nodes (values) into Map instance.
|
static OffsetDateTime |
toOffsetDateTime(String stringValue)
Maps
stringValue to OffsetDateTime. |
static OffsetTime |
toOffsetTime(String stringValue)
Maps
stringValue to OffsetTime. |
static Path |
toPath(String stringValue)
Maps
stringValue to Path. |
static Pattern |
toPattern(String stringValue)
Maps
stringValue to Pattern. |
static Period |
toPeriod(String stringValue)
Maps
stringValue to Period. |
static Properties |
toProperties(Config config)
Transform all leaf nodes (values) into Properties instance.
|
static Short |
toShort(String stringValue)
Maps
stringValue to short. |
static SimpleTimeZone |
toSimpleTimeZone(String stringValue)
Deprecated.
use new time API, such as
ZoneId |
static TimeZone |
toTimeZone(String stringValue)
Deprecated.
use new time API, such as
ZoneId |
static URI |
toUri(String stringValue)
Maps
stringValue to URI. |
static URL |
toUrl(String stringValue)
Maps
stringValue to URL. |
static UUID |
toUUID(String stringValue)
Maps
stringValue to UUID. |
static ZonedDateTime |
toZonedDateTime(String stringValue)
Maps
stringValue to ZonedDateTime. |
static ZoneId |
toZoneId(String stringValue)
Maps
stringValue to ZoneId. |
static ZoneOffset |
toZoneOffset(String stringValue)
Maps
stringValue to ZoneOffset. |
public static Byte toByte(String stringValue)
stringValue to byte.stringValue - source value as a StringstringValue to bytepublic static Short toShort(String stringValue)
stringValue to short.stringValue - source value as a StringstringValue to shortpublic static Integer toInt(String stringValue)
stringValue to int.stringValue - source value as a StringstringValue to intpublic static Long toLong(String stringValue)
stringValue to long.stringValue - source value as a StringstringValue to longpublic static Float toFloat(String stringValue)
stringValue to float.stringValue - source value as a StringstringValue to floatpublic static Double toDouble(String stringValue)
stringValue to double.stringValue - source value as a StringstringValue to doublepublic static Boolean toBoolean(String stringValue)
stringValue to boolean.stringValue - source value as a StringstringValue to booleanpublic static Character toChar(String stringValue)
stringValue to char.stringValue - source value as a StringstringValue to charpublic static Class<?> toClass(String stringValue)
stringValue to Class<?>.stringValue - source value as a StringstringValue to Class<?>public static UUID toUUID(String stringValue)
stringValue to UUID.stringValue - source value as a StringstringValue to UUIDpublic static BigDecimal toBigDecimal(String stringValue)
stringValue to BigDecimal.stringValue - source value as a StringstringValue to BigDecimalpublic static BigInteger toBigInteger(String stringValue)
stringValue to BigInteger.stringValue - source value as a StringstringValue to BigIntegerpublic static File toFile(String stringValue)
stringValue to File.stringValue - source value as a StringstringValue to Filepublic static Path toPath(String stringValue)
stringValue to Path.stringValue - source value as a StringstringValue to Pathpublic static Charset toCharset(String stringValue)
stringValue to Charset.stringValue - source value as a StringstringValue to Charsetpublic static Pattern toPattern(String stringValue)
stringValue to Pattern.stringValue - source value as a StringstringValue to Patternpublic static URI toUri(String stringValue)
stringValue to URI.stringValue - source value as a StringstringValue to URIpublic static URL toUrl(String stringValue)
stringValue to URL.stringValue - source value as a StringstringValue to URL@Deprecated public static Date toDate(String stringValue)
Instant or ZonedDateTimestringValue to Date.stringValue - source value as a StringstringValue to DateDateTimeFormatter.ISO_DATE_TIME@Deprecated public static Calendar toCalendar(String stringValue)
ZonedDateTimestringValue to Calendar.stringValue - source value as a StringstringValue to CalendarDateTimeFormatter.ISO_DATE_TIME@Deprecated public static GregorianCalendar toGregorianCalendar(String stringValue)
ZonedDateTimestringValue to GregorianCalendar.stringValue - source value as a StringstringValue to GregorianCalendarDateTimeFormatter.ISO_DATE_TIMEpublic static LocalDate toLocalDate(String stringValue)
stringValue to LocalDate.stringValue - source value as a StringstringValue to LocalDateLocalDate.parse(CharSequence)public static LocalTime toLocalTime(String stringValue)
stringValue to LocalTime.stringValue - source value as a StringstringValue to LocalTimeLocalTime.parse(CharSequence)public static LocalDateTime toLocalDateTime(String stringValue)
stringValue to LocalDateTime.stringValue - source value as a StringstringValue to LocalDateTimeLocalDateTime.parse(CharSequence)public static ZonedDateTime toZonedDateTime(String stringValue)
stringValue to ZonedDateTime.stringValue - source value as a StringstringValue to ZonedDateTimeZonedDateTime.parse(CharSequence)public static ZoneId toZoneId(String stringValue)
stringValue to ZoneId.stringValue - source value as a StringstringValue to ZoneIdZoneId.of(String)public static ZoneOffset toZoneOffset(String stringValue)
stringValue to ZoneOffset.stringValue - source value as a StringstringValue to ZoneOffsetZoneOffset.of(String)@Deprecated public static TimeZone toTimeZone(String stringValue)
ZoneIdstringValue to TimeZone.stringValue - source value as a StringstringValue to TimeZoneZoneId.of(String)@Deprecated public static SimpleTimeZone toSimpleTimeZone(String stringValue)
ZoneIdstringValue to SimpleTimeZone.stringValue - source value as a StringstringValue to SimpleTimeZoneZoneId.of(String)public static Instant toInstant(String stringValue)
stringValue to Instant.stringValue - source value as a StringstringValue to InstantInstant.parse(CharSequence)public static OffsetDateTime toOffsetDateTime(String stringValue)
stringValue to OffsetDateTime.stringValue - source value as a StringstringValue to OffsetDateTimeOffsetDateTime.parse(CharSequence)public static OffsetTime toOffsetTime(String stringValue)
stringValue to OffsetTime.stringValue - source value as a StringstringValue to OffsetTimeOffsetTime.parse(CharSequence)public static Duration toDuration(String stringValue)
stringValue to Duration.stringValue - source value as a StringstringValue to DurationDuration.parse(CharSequence)public static Period toPeriod(String stringValue)
stringValue to Period.stringValue - source value as a StringstringValue to PeriodPeriod.parse(CharSequence)public static Map<String,String> toMap(Config config)
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
Map app1 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.
Map<String, String> app2 = ConfigMappers.toMap(config.get("app").detach());
Map app2 contains two keys without app prefix: name, page-size.config - config node used to transform into PropertiesConfig.detach()public static Properties toProperties(Config config)
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
Properties app1 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());
Properties app2 contains two keys without app prefix: name, page-size.config - config node used to transform into PropertiesConfig.detach()Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.