Package dev.orne.beans.converters
Class DayOfWeekConverter
java.lang.Object
org.apache.commons.beanutils.converters.AbstractConverter
dev.orne.beans.converters.AbstractDateTimeConverter
dev.orne.beans.converters.DayOfWeekConverter
- All Implemented Interfaces:
org.apache.commons.beanutils.Converter
Implementation of
Converter
that converts DayOfWeek
instances
to and from String
constant name as String
representation.- Since:
- 0.1
- Version:
- 1.0, 2020-05
- Author:
- (w) Iker Hernaez
-
Field Summary
Modifier and TypeFieldDescriptionstatic final DateTimeFormatter
The day of week by full text parser, for default locale.static final DateTimeFormatter
The day of week by short text parser, for default locale.static final DateTimeFormatter
The day of week by short text parser, for default locale.static final DateTimeFormatter
The day of week by value parser. -
Constructor Summary
ConstructorDescriptionCreates a new instance that throws aConversionException
if an error occurs.DayOfWeekConverter
(@NotNull DateTimeFormatter formatter) Creates a new instance that throws aConversionException
if an error occurs.DayOfWeekConverter
(@NotNull DateTimeFormatter formatter, DayOfWeek defaultValue) Creates a new instance that returns a default value if an error occurs.DayOfWeekConverter
(DayOfWeek defaultValue) Creates a new instance that returns a default value if an error occurs. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
convertToString
(Object value) protected <T> T
convertToType
(@NotNull Class<T> type, Object value) protected <T extends TemporalAccessor>
TfromTemporalAccessor
(@NotNull Class<T> type, @NotNull TemporalAccessor value) Converts theTemporalAccessor
passed as argument to the specified type.protected @NotNull Class<?>
Methods inherited from class dev.orne.beans.converters.AbstractDateTimeConverter
addParsers, addParsers, getFormatter, getLogger, getParsers, parse, parseString, setParsers, setParsers
Methods inherited from class org.apache.commons.beanutils.converters.AbstractConverter
conversionException, convert, convertArray, getDefault, handleError, handleMissing, isUseDefault, setDefaultValue, toString
-
Field Details
-
BY_VALUE_PARSER
The day of week by value parser. -
BY_FULL_TEXT_PARSER
The day of week by full text parser, for default locale. -
BY_SHORT_TEXT_PARSER
The day of week by short text parser, for default locale. -
BY_NARROW_TEXT_PARSER
The day of week by short text parser, for default locale.
-
-
Constructor Details
-
DayOfWeekConverter
public DayOfWeekConverter()Creates a new instance that throws aConversionException
if an error occurs. -
DayOfWeekConverter
Creates a new instance that returns a default value if an error occurs.- Parameters:
defaultValue
- The default value to be returned if the value to be converted is missing or an error occurs converting the value
-
DayOfWeekConverter
Creates a new instance that throws aConversionException
if an error occurs.- Parameters:
formatter
- The temporal value formatter and default parser
-
DayOfWeekConverter
Creates a new instance that returns a default value if an error occurs.- Parameters:
formatter
- The temporal value formatter and default parserdefaultValue
- The default value to be returned if the value to be converted is missing or an error occurs converting the value
-
-
Method Details
-
getDefaultType
- Specified by:
getDefaultType
in classAbstractDateTimeConverter
-
convertToType
- Overrides:
convertToType
in classAbstractDateTimeConverter
-
fromTemporalAccessor
protected <T extends TemporalAccessor> T fromTemporalAccessor(@NotNull @NotNull Class<T> type, @NotNull @NotNull TemporalAccessor value) Converts theTemporalAccessor
passed as argument to the specified type.- Specified by:
fromTemporalAccessor
in classAbstractDateTimeConverter
- Type Parameters:
T
- The expected type ofTemporalAccessor
- Parameters:
type
- The expected type ofTemporalAccessor
value
- TheTemporalAccessor
to convert to the expected type- Returns:
- The converted
TemporalAccessor
of the expected type
-
convertToString
- Overrides:
convertToString
in classAbstractDateTimeConverter
-