Class CoercionTuple<S,T>
java.lang.Object
org.apache.tapestry5.commons.services.CoercionTuple<S,T>
- Type Parameters:
S- source (input) typeT- target (output) type
An immutable object that represents a mapping from one type to another. This is also the contribution type when
building the
TypeCoercer service. Wraps a
Coercion object that performs the work with additional properties that
describe
the input and output types of the coercion, needed when searching for an appropriate coercion (or sequence of
coercions).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classClass that represents the key to be used to the mapped configuration of theTypeCoercerservice. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <S,T> void add(MappedConfiguration<CoercionTuple.Key, CoercionTuple> configuration, Class<S> sourceType, Class<T> targetType, Coercion<S, T> coercion) Convenience method to create a coercion tuple using create(Class, Class, Coercion) and add it to a MappedConfiguration in a single step.static <S,T> CoercionTuple<S, T> Convenience constructor to help with generics.getKey()static <S,T> void override(MappedConfiguration<CoercionTuple.Key, CoercionTuple> configuration, Class<S> sourceType, Class<T> targetType, Coercion<S, T> coercion) Convenience method to create a coercion tuple using create(Class, Class, Coercion) and override a matching one in a MappedConfiguration in a single step.toString()
-
Constructor Details
-
CoercionTuple
Standard constructor, which defaults wrap to true. -
CoercionTuple
public CoercionTuple(Class<S> sourceType, Class<T> targetType, Coercion<S, T> coercion, boolean wrap) Internal-use constructor.- Parameters:
sourceType- the source (or input) type of the coercion, may be Void.class to indicate a coercion from nulltargetType- the target (or output) type of the coercioncoercion- the object that performs the coercionwrap- if true, the coercion is wrapped to provide a useful toString()
-
-
Method Details
-
add
public static <S,T> void add(MappedConfiguration<CoercionTuple.Key, CoercionTuple> configuration, Class<S> sourceType, Class<T> targetType, Coercion<S, T> coercion) Convenience method to create a coercion tuple using create(Class, Class, Coercion) and add it to a MappedConfiguration in a single step.- Since:
- 5.8.0
-
override
public static <S,T> void override(MappedConfiguration<CoercionTuple.Key, CoercionTuple> configuration, Class<S> sourceType, Class<T> targetType, Coercion<S, T> coercion) Convenience method to create a coercion tuple using create(Class, Class, Coercion) and override a matching one in a MappedConfiguration in a single step.- Since:
- 5.8.0
-
create
public static <S,T> CoercionTuple<S,T> create(Class<S> sourceType, Class<T> targetType, Coercion<S, T> coercion) Convenience constructor to help with generics.- Since:
- 5.2.0
-
toString
-
getCoercion
-
getSourceType
-
getTargetType
-
getKey
-