接口 FormatterRegistry
- 所有超级接口:
ConverterRegistry
public interface FormatterRegistry extends ConverterRegistry
A registry of field formatting logic.- 从以下版本开始:
- 3.0
- 作者:
- Keith Donald, Juergen Hoeller
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
addFormatter(Formatter<?> formatter)
Adds a Formatter to format fields of a specific type.void
addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory)
Adds a Formatter to format fields annotated with a specific format annotation.void
addFormatterForFieldType(Class<?> fieldType, Formatter<?> formatter)
Adds a Formatter to format fields of the given type.void
addFormatterForFieldType(Class<?> fieldType, Printer<?> printer, Parser<?> parser)
Adds a Printer/Parser pair to format fields of a specific type.void
addParser(Parser<?> parser)
Adds a Parser to parse fields of a specific type.void
addPrinter(Printer<?> printer)
Adds a Printer to print fields of a specific type.从接口继承的方法 org.springframework.core.convert.converter.ConverterRegistry
addConverter, addConverter, addConverter, addConverterFactory, removeConvertible
方法详细资料
addPrinter
void addPrinter(Printer<?> printer)
Adds a Printer to print fields of a specific type. The field type is implied by the parameterized Printer instance.- 参数:
printer
- the printer to add- 从以下版本开始:
- 5.2
- 另请参阅:
addFormatter(Formatter)
addParser
void addParser(Parser<?> parser)
Adds a Parser to parse fields of a specific type. The field type is implied by the parameterized Parser instance.- 参数:
parser
- the parser to add- 从以下版本开始:
- 5.2
- 另请参阅:
addFormatter(Formatter)
addFormatter
void addFormatter(Formatter<?> formatter)
Adds a Formatter to format fields of a specific type. The field type is implied by the parameterized Formatter instance.- 参数:
formatter
- the formatter to add- 从以下版本开始:
- 3.1
- 另请参阅:
addFormatterForFieldType(Class, Formatter)
addFormatterForFieldType
void addFormatterForFieldType(Class<?> fieldType, Formatter<?> formatter)
Adds a Formatter to format fields of the given type.On print, if the Formatter's type T is declared and
fieldType
is not assignable to T, a coercion to T will be attempted before delegating toformatter
to print a field value. On parse, if the parsed object returned byformatter
is not assignable to the runtime field type, a coercion to the field type will be attempted before returning the parsed field value.- 参数:
fieldType
- the field type to formatformatter
- the formatter to add
addFormatterForFieldType
void addFormatterForFieldType(Class<?> fieldType, Printer<?> printer, Parser<?> parser)
Adds a Printer/Parser pair to format fields of a specific type. The formatter will delegate to the specifiedprinter
for printing and the specifiedparser
for parsing.On print, if the Printer's type T is declared and
fieldType
is not assignable to T, a coercion to T will be attempted before delegating toprinter
to print a field value. On parse, if the object returned by the Parser is not assignable to the runtime field type, a coercion to the field type will be attempted before returning the parsed field value.- 参数:
fieldType
- the field type to formatprinter
- the printing part of the formatterparser
- the parsing part of the formatter
addFormatterForFieldAnnotation
void addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory)
Adds a Formatter to format fields annotated with a specific format annotation.- 参数:
annotationFormatterFactory
- the annotation formatter factory to add