Class DurationTypeHandler
java.lang.Object
ch.tocco.nice2.types.spi.TypeHandlerWrapper<Long>
ch.tocco.nice2.types.impl.handlers.DurationTypeHandler
- All Implemented Interfaces:
TypeHandler<Long>
String syntax: Either just an amount of millis or:
TODO Change syntax to require hours:minutes:seconds in input, and always output at least these parts.
Only the leftmost input value (hours) may overflow, eg 48:30:59 but not 8:61:00 in asObject().
Atm a value like "8:30" is mm:ss which is misleading depending on context. This change is for
disambiguation, and is in compliance with the types.DurationUtil.
Also, the input must allow negative values (minus sign in front of the whole string).
[[<days>d]<hours>:]<minutes>:<seconds>[.<millis>]
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
static final Pattern
Groups: 3: days (optional) 6: hours (optional) 7: minutes 8: seconds 10: millis (optional) OR 11: millisstatic final long
static final long
static final long
Fields inherited from class ch.tocco.nice2.types.spi.TypeHandlerWrapper
baseHandler, type
-
Constructor Summary
-
Method Summary
Methods inherited from class ch.tocco.nice2.types.spi.TypeHandlerWrapper
compare, contains, getEmptyValue, init, invalid, invalid, isBoolean, isChronological, isEqual, isNumeric, isolate, matches
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.types.spi.TypeHandler
getGenerationType
-
Field Details
-
DURATION_RE
Groups:- 3: days (optional)
- 6: hours (optional)
- 7: minutes
- 8: seconds
- 10: millis (optional)
- 11: millis
-
SECOND
public static final long SECOND- See Also:
-
MINUTE
public static final long MINUTE- See Also:
-
HOUR
public static final long HOUR- See Also:
-
DAY
public static final long DAY- See Also:
-
-
Constructor Details
-
DurationTypeHandler
public DurationTypeHandler()
-
-
Method Details
-
shouldBeUnique
public boolean shouldBeUnique()- Specified by:
shouldBeUnique
in interfaceTypeHandler<Long>
- Overrides:
shouldBeUnique
in classTypeHandlerWrapper<Long>
- See Also:
-
asObject
- Specified by:
asObject
in interfaceTypeHandler<Long>
- Overrides:
asObject
in classTypeHandlerWrapper<Long>
- Throws:
StringConversionException
-
asString
- Specified by:
asString
in interfaceTypeHandler<Long>
- Overrides:
asString
in classTypeHandlerWrapper<Long>
-
validate
public boolean validate(@Nullable @Nullable Long value, boolean exception) throws ValidationException - Specified by:
validate
in interfaceTypeHandler<Long>
- Overrides:
validate
in classTypeHandlerWrapper<Long>
- Throws:
ValidationException
- See Also:
-