Annotation Interface StaticFactory
Generate a static factory method for the annotated constructor.
Note private constructors will be ignored.
This annotation takes precedence over @StaticFactories and it can be applied to any non-private constructor.
Example
public final class FactoryFoo
{
public FactoryFoo(@Nonnull final String s)
{
this(s, 0);
}
@StaticFactory("Foo")
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, int i) {
return new FactoryFoo(s,i);
}
}
- See Also:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe name of the factory method.The name of the package where to put the class containing the static factory methods.
-
Element Details
-
value
String valueThe name of the class containing the static factory methods.
-
-
-
packageName
String packageNameThe 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:
- ""
-
methodName
String methodNameThe name of the factory method. By default, it's a lower case version of the annotated class' name.Setting this may be necessary when the lower case version of a class name results in a reserved keyword.
- Default:
- ""
-