Package play.data.format
Class Formatters
java.lang.Object
play.data.format.Formatters
Formatters helper.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFormatters.AnnotationFormatter<A extends Annotation,T> Super-type for annotation-based formatters.static classSuper-type for custom simple formatters. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal org.springframework.format.support.FormattingConversionServiceThe underlying conversion service. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TParses this string as instance of a specific field<T> TParses this string as instance of the given class.<T> StringComputes the display string for any value, for a specific field.<T> Stringprint(org.springframework.core.convert.TypeDescriptor desc, T t) Computes the display string for any value, for a specific type.<T> Stringprint(T t) Computes the display string for any value.<A extends Annotation,T>
Formattersregister(Class<T> clazz, Formatters.AnnotationFormatter<A, T> formatter) Registers an annotation-based formatter.<T> Formattersregister(Class<T> clazz, Formatters.SimpleFormatter<T> formatter) Registers a simple formatter.
-
Field Details
-
conversion
public final org.springframework.format.support.FormattingConversionService conversionThe underlying conversion service.
-
-
Constructor Details
-
Formatters
-
-
Method Details
-
parse
Parses this string as instance of the given class.- Type Parameters:
T- the type to parse out of the text- Parameters:
text- the text to parseclazz- class representing the required type- Returns:
- the parsed value
-
parse
Parses this string as instance of a specific field- Type Parameters:
T- the type to parse out of the text- Parameters:
field- the related field (custom formatters are extracted from this field annotation)text- the text to parse- Returns:
- the parsed value
-
print
Computes the display string for any value.- Type Parameters:
T- the type to print- Parameters:
t- the value to print- Returns:
- the formatted string
-
print
Computes the display string for any value, for a specific field.- Type Parameters:
T- the type to print- Parameters:
field- the related field - custom formatters are extracted from this field annotationt- the value to print- Returns:
- the formatted string
-
print
Computes the display string for any value, for a specific type.- Type Parameters:
T- the type to print- Parameters:
desc- the field descriptor - custom formatters are extracted from this descriptor.t- the value to print- Returns:
- the formatted string
-
register
Registers a simple formatter.- Type Parameters:
T- the type that this formatter will parse and print- Parameters:
clazz- class handled by this formatterformatter- the formatter to register- Returns:
- the modified Formatters object.
-
register
public <A extends Annotation,T> Formatters register(Class<T> clazz, Formatters.AnnotationFormatter<A, T> formatter) Registers an annotation-based formatter.- Type Parameters:
A- the annotation typeT- the type that will be parsed or printed- Parameters:
clazz- class handled by this formatterformatter- the formatter to register- Returns:
- the modified Formatters object.
-