Annotation Interface Converters


@Target({TYPE,FIELD}) @Retention(RUNTIME) @Inherited @Documented public @interface Converters

Handles implicit and explicit converter creation. KlumAST creates converter methods from all "factory-like" methods in the target class. A factory-like method is a public static method that returns the specified type or one of its subclasses and whose name matches one of the prefixes: from, of, create, parse.

Note that the annotation on a field completely replaces the annotation on the class for that field.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    If set to false, the default prefixes are ignored.
    Prefixes of static methods that should not be considered factories.
    boolean
    If set to true, public constructors of a target class are used for converters as well.
    Prefixes of static methods that are considered factories.
    Additional classes that are searched for factory methods.
  • Element Details

    • includeMethods

      String[] includeMethods
      Prefixes of static methods that are considered factories.
      Default:
      {}
    • excludeMethods

      String[] excludeMethods
      Prefixes of static methods that should not be considered factories. If both includes and excludes are defined, excludes wins over includes, i.e. methods that are included can later be excluded.
      Default:
      {}
    • excludeDefaultPrefixes

      boolean excludeDefaultPrefixes
      If set to false, the default prefixes are ignored. In that case, only explicitly defined includes (or ALL methods, if no includes are set!) are considered.
      Default:
      false
    • value

      Class[] value
      Additional classes that are searched for factory methods.
      Default:
      {}
    • includeConstructors

      boolean includeConstructors
      If set to true, public constructors of a target class are used for converters as well.
      Default:
      false