net.stickycode.coercion
Interface Coercion<T>

Type Parameters:
T - The type that can be converted to

public interface Coercion<T>

Contract for a converter of strings to a defined type.


Method Summary
 T coerce(CoercionTarget type, String value)
          Coerce the given string value into the type represented by this coercion.
 T getDefaultValue(CoercionTarget target)
          In the case where there is not value already set and a String value for coercion cannot be found then this will be used.
 boolean hasDefaultValue()
          For some coercions a default value on the coercion itself makes sense.
 boolean isApplicableTo(CoercionTarget target)
          Return true if this coercion is applicable for the given target type
 String toString()
          Description of the coercion useful for logging
 

Method Detail

coerce

T coerce(CoercionTarget type,
         String value)
Coerce the given string value into the type represented by this coercion.

Parameters:
value - The string value to convert. WILL NOT be null.
Returns:
A non null string value

isApplicableTo

boolean isApplicableTo(CoercionTarget target)
Return true if this coercion is applicable for the given target type


hasDefaultValue

boolean hasDefaultValue()
For some coercions a default value on the coercion itself makes sense.


getDefaultValue

T getDefaultValue(CoercionTarget target)
In the case where there is not value already set and a String value for coercion cannot be found then this will be used.


toString

String toString()
Description of the coercion useful for logging

Overrides:
toString in class Object


Copyright © 2003-2012 RedEngine Ltd. All Rights Reserved.