Annotation Interface StaticFactories


@Target(TYPE) @Retention(SOURCE) public @interface StaticFactories
Generate a static factory method for each public constructor of the annotated class.

Example

 @StaticFactories("Foo")
 public final class FactoryFoo
 {
     public FactoryFoo(@Nonnull final String s)
     {
         this(s, 0);
     }


     public FactoryFoo(@Nonnull final String s, int i)
     {
     }
 }
 

generates


 public final class Foo {
     private Foo() {
         // no-instances constructor
     }

     public static FactoryFoo factoryFoo(@Nonnull final String s) {
         return new FactoryFoo(s);
     }

     public static FactoryFoo factoryFoo(@Nonnull final String s, int i) {
         return new FactoryFoo(s,i);
     }
 }
 
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the class containing the static factory methods.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The name of the package where to put the class containing the static factory methods.
  • Element Details

    • value

      String value
      The name of the class containing the static factory methods.
    • packageName

      String packageName
      The name of the package where to put the class containing the static factory methods.

      By default, the class will be created in the same package as the annotated class.

      Default:
      ""