org.jpatterns.gof.FactoryMethodPattern Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jpatterns Show documentation
Show all versions of jpatterns Show documentation
Design Patterns are typically encoded into Java code in an ad-hoc fashion.
They are either embedded into the names of the classes or written into the
Javadocs.
Unfortunately it is impossible to accurately determine a pattern based
solely on the
class structure without knowing the intent of the code author.
JPatterns is a collection of annotations that make it easy to communicate
the use
of (Design)Patterns within your code to your fellow developers and your
future self.
The newest version!
package org.jpatterns.gof;
import org.jpatterns.core.*;
import java.lang.annotation.*;
/**
* Intent [GoF, pg 107]: Define an interface for creating an object, but
* let subclasses decide which class to instantiate. Factory Method lets a class
* defer instantiation to subclasses.
*
* This pattern refers to the GoF factory method, which differs greatly from the
* static factory method commonly found in the refactoring literature.
*
*
*
* @author Heinz Kabutz
* @since 2010-08-09
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@DesignPattern(type = Type.CREATIONAL,
related = {AbstractFactoryPattern.class, TemplateMethodPattern.class,
PrototypePattern.class})
public @interface FactoryMethodPattern {
Class[] participants() default {};
String comment() default "";
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
public @interface Creator {
Class[] participants() default {};
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
public @interface Product {
Class[] participants() default {};
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
public @interface ConcreteCreator {
Class[] participants() default {};
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
public @interface ConcreteProduct {
Class[] participants() default {};
String comment() default "";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy