org.springframework.format

Interface FormatterRegistry

    • Method Detail

      • 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.
        Parameters:
        formatter - the formatter to add
        Since:
        3.1
        See Also:
        addFormatterForFieldType(Class, Formatter)
      • addFormatterForFieldType

        void addFormatterForFieldType(java.lang.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 to formatter to print a field value. On parse, if the parsed object returned by formatter is not assignable to the runtime field type, a coercion to the field type will be attempted before returning the parsed field value.

        Parameters:
        fieldType - the field type to format
        formatter - the formatter to add
      • addFormatterForFieldType

        void addFormatterForFieldType(java.lang.Class<?> fieldType,
                                      Printer<?> printer,
                                      Parser<?> parser)
        Adds a Printer/Parser pair to format fields of a specific type. The formatter will delegate to the specified printer for printing and the specified parser 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 to printer 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.

        Parameters:
        fieldType - the field type to format
        printer - the printing part of the formatter
        parser - the parsing part of the formatter
      • addFormatterForFieldAnnotation

        void addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends java.lang.annotation.Annotation> annotationFormatterFactory)
        Adds a Formatter to format fields annotated with a specific format annotation.
        Parameters:
        annotationFormatterFactory - the annotation formatter factory to add