Package org.silverpeas.core.date
Class TemporalConverter.Conversion<T extends Temporal,R>
- java.lang.Object
-
- org.silverpeas.core.date.TemporalConverter.Conversion<T,R>
-
- Type Parameters:
T
- the concrete type of the temporal object this conversion function accepts.R
- the concrete type of the converted value.
- Enclosing class:
- TemporalConverter
public static class TemporalConverter.Conversion<T extends Temporal,R> extends Object
A conversion function of a temporal object into a value of type R.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accepts(Temporal temporal)
Does this conversion function accepts to the type of the specified temporal object.R
apply(Temporal temporal)
Applies the conversion to the specifiedTemporal
object.String
getAcceptedType()
Gets the simple name of the concrete type ofTemporal
objects this conversion function accepts as argument.static <T extends Temporal,R>
TemporalConverter.Conversion<T,R>of(Class<T> type, Function<T,R> converter)
Constructs a conversion function that will apply to the specified concrete type ofTemporal
objects and that will return a value of the specified concrete type R.
-
-
-
Method Detail
-
of
public static <T extends Temporal,R> TemporalConverter.Conversion<T,R> of(Class<T> type, Function<T,R> converter)
Constructs a conversion function that will apply to the specified concrete type ofTemporal
objects and that will return a value of the specified concrete type R.- Type Parameters:
T
- the acceptedTemporal
concrete type.R
- the type to which the temporal objects will be converted.- Parameters:
type
- the expected concrete type of theTemporal
objects to convert.converter
- the temporal conversion implementation.- Returns:
- a
TemporalConverter.Conversion
instance.
-
accepts
public boolean accepts(Temporal temporal)
Does this conversion function accepts to the type of the specified temporal object.
-
apply
public R apply(Temporal temporal)
Applies the conversion to the specifiedTemporal
object.- Parameters:
temporal
- aTemporal
object. Must be of type T otherwise aClassCastException
is thrown.- Returns:
- a value of type R, issued from the conversion of the
Temporal
object.
-
-