Annotation Interface Option.Singular

Enclosing class:
Option

@Target(METHOD) @Retention(CLASS) public static @interface Option.Singular
Applying this annotation to a Prototype.Blueprint-annotated interface method will cause the generated class to also include additional "add*()" methods. This will only apply, however, if the method is for a Map, List, or Set.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The optional value specified here will determine the singular form of the method name.
    boolean
    When set to true, the prefix add or put will be added to generated methods (for collections and maps respectively).
  • Element Details

    • value

      String value
      The optional value specified here will determine the singular form of the method name. For instance, if we take a method like this:
      
       @Singlular("pickle")
       List<Pickle> getPickles();
       
      an additional generated method named addPickle(Pickle val) will be placed on the builder of the generated class.

      This annotation only applies to getter methods that return a Map, List, or Set. If left undefined then the add method will use the default method name, dropping any "s" that might be present at the end of the method name (e.g., pickles -> pickle).

      Returns:
      The singular name to add
      Default:
      ""
    • withPrefix

      boolean withPrefix
      When set to true, the prefix add or put will be added to generated methods (for collections and maps respectively). When set to false, the value() will be used as a full method name for singular add/put methods.

      In case you set this to false, you must make sure the method name does not conflict with other methods on the generated type

      Returns:
      whether to add prefix to the generated method, defaults to true
      Default:
      true