diff --git a/.gitignore b/.gitignore index 4588240..c06cfde 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target/ .classpath .project .settings +.idea/ \ No newline at end of file diff --git a/jpatterns.iml b/jpatterns.iml deleted file mode 100644 index 83ea572..0000000 --- a/jpatterns.iml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jpatterns.iws b/jpatterns.iws deleted file mode 100644 index 9fd9ea3..0000000 --- a/jpatterns.iws +++ /dev/null @@ -1,2144 +0,0 @@ -<<<<<<< HEAD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Inspections - - - - - Abstraction issues - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - localhost - 5050 - - - - - - - - - - - - - - 1279137760557 - 1279137760557 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -======= - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Inspections - - - - - Abstraction issues - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - localhost - 5050 - - - - - - - - - - - - 1279137760557 - 1279137760557 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.5 - - - - - - - - - - - - - - - - - ->>>>>>> 2fb6d980cb6611b0c2a537e94959fb56ed34d062 diff --git a/pom.xml b/pom.xml index 9e3441c..7a047e6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,99 +1,97 @@ - - - 4.0.0 - - - org.sonatype.oss - oss-parent - 7 - - - org.jpatterns - jpatterns - 0.0.1 - jar - Java Design Pattern Annotations - - 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. - - http://jpatterns.org - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - http://github.com/jexp/jpatterns - git://github.com/jexp/jpatterns.git - git@github.com:jexp/jpatterns.git - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.5 - 1.5 - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.7 - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - - jar - - - - - - - - - - junit - junit-dep - 4.5 - test - - - org.easymock - easymock - 2.4 - test - - - - - + + + 4.0.0 + + + org.sonatype.oss + oss-parent + 7 + + + org.jpatterns + jpatterns + 0.1 + jar + Java Design Pattern Annotations + + 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. + + http://jpatterns.org + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + http://github.com/jexp/jpatterns + git://github.com/jexp/jpatterns.git + git@github.com:jexp/jpatterns.git + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 8 + 8 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.7 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + + + + + junit + junit + 4.13.2 + test + + + org.easymock + easymock + 2.4 + test + + + \ No newline at end of file diff --git a/src/main/java/org/jpatterns/core/DesignPattern.java b/src/main/java/org/jpatterns/core/DesignPattern.java index c0b862e..e3c71b3 100644 --- a/src/main/java/org/jpatterns/core/DesignPattern.java +++ b/src/main/java/org/jpatterns/core/DesignPattern.java @@ -1,6 +1,11 @@ package org.jpatterns.core; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * @author Michael Hunger @@ -11,13 +16,13 @@ @Documented @Inherited public @interface DesignPattern { - Source source() default Source.GoF; + Source source() default Source.GoF; - Type type(); + Type type(); - String[] urls() default {}; + String[] urls() default {}; - Refactoring[] refactorings() default {}; + Refactoring[] refactorings() default {}; - Class[] related() default {}; + Class[] related() default {}; } diff --git a/src/main/java/org/jpatterns/core/Refactoring.java b/src/main/java/org/jpatterns/core/Refactoring.java index ea949b6..fde0a22 100644 --- a/src/main/java/org/jpatterns/core/Refactoring.java +++ b/src/main/java/org/jpatterns/core/Refactoring.java @@ -5,5 +5,5 @@ * @since 2010-08-08 */ public enum Refactoring { - ExtractMethodObject, ExtractParameterObject + ExtractMethodObject, ExtractParameterObject } diff --git a/src/main/java/org/jpatterns/core/Source.java b/src/main/java/org/jpatterns/core/Source.java index 17e366c..5c282ca 100644 --- a/src/main/java/org/jpatterns/core/Source.java +++ b/src/main/java/org/jpatterns/core/Source.java @@ -5,5 +5,5 @@ * @since 2010-07-14 */ public enum Source { - GoF, POSA, PoEAA, PLoPD3, CoreJ2EE, Other, Hophe + GoF, POSA, PoEAA, PLoPD3, CoreJ2EE, Other, Hophe } diff --git a/src/main/java/org/jpatterns/core/Type.java b/src/main/java/org/jpatterns/core/Type.java index 0dfafbb..fc85faa 100644 --- a/src/main/java/org/jpatterns/core/Type.java +++ b/src/main/java/org/jpatterns/core/Type.java @@ -5,5 +5,5 @@ * @since 2010-07-14 */ public enum Type { - CREATIONAL, STRUCTURAL, BEHAVIORAL, USER_INTERFACE, MESSAGING, ENTERPRISE + CREATIONAL, STRUCTURAL, BEHAVIORAL, USER_INTERFACE, MESSAGING, ENTERPRISE } \ No newline at end of file diff --git a/src/main/java/org/jpatterns/doc/PatternComment.java b/src/main/java/org/jpatterns/doc/PatternComment.java index 0937399..9941a3f 100644 --- a/src/main/java/org/jpatterns/doc/PatternComment.java +++ b/src/main/java/org/jpatterns/doc/PatternComment.java @@ -1,6 +1,11 @@ package org.jpatterns.doc; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * @author Heinz Kabutz @@ -9,16 +14,16 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ - ElementType.TYPE, - ElementType.CONSTRUCTOR, - ElementType.FIELD, - ElementType.LOCAL_VARIABLE, - ElementType.METHOD, - ElementType.PARAMETER - }) + ElementType.TYPE, + ElementType.CONSTRUCTOR, + ElementType.FIELD, + ElementType.LOCAL_VARIABLE, + ElementType.METHOD, + ElementType.PARAMETER +}) @Documented @Inherited @Deprecated public @interface PatternComment { - String value(); + String value(); } diff --git a/src/main/java/org/jpatterns/doc/PatternParticipants.java b/src/main/java/org/jpatterns/doc/PatternParticipants.java index f9287e1..fc24711 100644 --- a/src/main/java/org/jpatterns/doc/PatternParticipants.java +++ b/src/main/java/org/jpatterns/doc/PatternParticipants.java @@ -1,6 +1,11 @@ package org.jpatterns.doc; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * @author Heinz Kabutz @@ -9,16 +14,16 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ - ElementType.TYPE, - ElementType.CONSTRUCTOR, - ElementType.FIELD, - ElementType.LOCAL_VARIABLE, - ElementType.METHOD, - ElementType.PARAMETER - }) + ElementType.TYPE, + ElementType.CONSTRUCTOR, + ElementType.FIELD, + ElementType.LOCAL_VARIABLE, + ElementType.METHOD, + ElementType.PARAMETER +}) @Documented @Inherited @Deprecated public @interface PatternParticipants { - Class[] value(); + Class[] value(); } diff --git a/src/main/java/org/jpatterns/gof/AbstractFactoryPattern.java b/src/main/java/org/jpatterns/gof/AbstractFactoryPattern.java index ef3af0c..d130008 100644 --- a/src/main/java/org/jpatterns/gof/AbstractFactoryPattern.java +++ b/src/main/java/org/jpatterns/gof/AbstractFactoryPattern.java @@ -1,73 +1,78 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 87]: Provide an interface for creating families of - * related or dependent objects without specifying their concrete classes. - *

- * - *

- * - * - * @author Heinz Kabutz, Michael Hunger - * @since 2010-08-09 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.CREATIONAL, - related = {FactoryMethodPattern.class, PrototypePattern.class, - SingletonPattern.class}) -public @interface AbstractFactoryPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface AbstractProduct { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteProduct { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - @Documented - public @interface FactoryMethod { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface AbstractFactory { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteFactory { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 87]: Provide an interface for creating families of + * related or dependent objects without specifying their concrete classes. + *

+ * Abstract Factory Structure + *

+ * Abstract Factory User View Structure + * + * @author Heinz Kabutz, Michael Hunger + * @since 2010-08-09 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.CREATIONAL, + related = {FactoryMethodPattern.class, PrototypePattern.class, + SingletonPattern.class}) +public @interface AbstractFactoryPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface AbstractProduct { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteProduct { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @Documented + public @interface FactoryMethod { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface AbstractFactory { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteFactory { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/AdapterPattern.java b/src/main/java/org/jpatterns/gof/AdapterPattern.java index a17200e..c0edb57 100644 --- a/src/main/java/org/jpatterns/gof/AdapterPattern.java +++ b/src/main/java/org/jpatterns/gof/AdapterPattern.java @@ -1,65 +1,68 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 139]: Convert the interface of a class into another - * interface clients expect. Adapter lets classes work together that couldn't - * otherwise because of incompatible interfaces. - *

- * The structure for an object adapter is: - *

- * - *

- * The structure for a class adapter is: - *

- * - * - * @author Heinz Kabutz - * @since 2010-07-28 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.STRUCTURAL, - related = {BridgePattern.class, DecoratorPattern.class, ProxyPattern.class}) -public @interface AdapterPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Adapter { - Class[] participants() default {}; - - String comment() default ""; - - Variation value() default Variation.OBJECT; - } - - /** - * We would hardly ever use this annotation as the adaptee is - * usually not aware that he is being adapted. - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Adaptee { - Class[] participants() default {}; - - String comment() default ""; - } - - public enum Variation { - OBJECT, - CLASS, - /** - * See http://www.javaspecialists.eu/archive/Issue108.html - */ - DYNAMIC - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 139]: Convert the interface of a class into another + * interface clients expect. Adapter lets classes work together that couldn't + * otherwise because of incompatible interfaces. + *

+ * The structure for an object adapter is: + * Object Adapter Structure + *

+ * The structure for a class adapter is: + * Class Adapter Structure + * + * @author Heinz Kabutz + * @since 2010-07-28 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.STRUCTURAL, + related = {BridgePattern.class, DecoratorPattern.class, ProxyPattern.class}) +public @interface AdapterPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Adapter { + Class[] participants() default {}; + + String comment() default ""; + + Variation value() default Variation.OBJECT; + } + + /** + * We would hardly ever use this annotation as the adaptee is + * usually not aware that he is being adapted. + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Adaptee { + Class[] participants() default {}; + + String comment() default ""; + } + + public enum Variation { + OBJECT, + CLASS, + /** + * See http://www.javaspecialists.eu/archive/Issue108.html + */ + DYNAMIC + } +} diff --git a/src/main/java/org/jpatterns/gof/BridgePattern.java b/src/main/java/org/jpatterns/gof/BridgePattern.java index 776e600..5597888 100644 --- a/src/main/java/org/jpatterns/gof/BridgePattern.java +++ b/src/main/java/org/jpatterns/gof/BridgePattern.java @@ -1,61 +1,66 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 151]: Decouple an abstraction from its implementation - * so that the two can vary independently. - *

- * - * - * @author Heinz Kabutz - * @since 2010-07-28 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.STRUCTURAL, - related = {AbstractFactoryPattern.class, AdapterPattern.class}) -public @interface BridgePattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Abstraction { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface RefinedAbstraction { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Implementor { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteImplementor { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 151]: Decouple an abstraction from its implementation + * so that the two can vary independently. + *

+ * Bridge Structure + * + * @author Heinz Kabutz + * @since 2010-07-28 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.STRUCTURAL, + related = {AbstractFactoryPattern.class, AdapterPattern.class}) +public @interface BridgePattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Abstraction { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface RefinedAbstraction { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Implementor { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteImplementor { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/BuilderPattern.java b/src/main/java/org/jpatterns/gof/BuilderPattern.java index 2e3ada2..02c40f0 100644 --- a/src/main/java/org/jpatterns/gof/BuilderPattern.java +++ b/src/main/java/org/jpatterns/gof/BuilderPattern.java @@ -1,8 +1,13 @@ package org.jpatterns.gof; -import org.jpatterns.core.*; +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * Intent [GoF, pg 97]: Separate the construction of a complex object @@ -16,46 +21,46 @@ @Target(ElementType.TYPE) @Documented @DesignPattern(type = Type.CREATIONAL, - related = {AbstractFactoryPattern.class, CompositePattern.class}) + related = {AbstractFactoryPattern.class, CompositePattern.class}) public @interface BuilderPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Director { Class[] participants() default {}; String comment() default ""; - } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Builder { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Director { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteBuilder { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Builder { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Product { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteBuilder { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Product { + Class[] participants() default {}; + + String comment() default ""; + } } diff --git a/src/main/java/org/jpatterns/gof/ChainOfResponsibilityPattern.java b/src/main/java/org/jpatterns/gof/ChainOfResponsibilityPattern.java index 39c67b8..ceac72f 100644 --- a/src/main/java/org/jpatterns/gof/ChainOfResponsibilityPattern.java +++ b/src/main/java/org/jpatterns/gof/ChainOfResponsibilityPattern.java @@ -1,47 +1,52 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 223]: Avoid coupling the sender of a request to its - * receiver by giving more than one object a chance to handle the request. Chain - * the receiving objects and pass the request along the chain until an object - * handles it. - *

- * - * - * @author Heinz Kabutz - * @since 2010-07-28 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.BEHAVIORAL, - related = {CompositePattern.class}) -public @interface ChainOfResponsibilityPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Handler { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteHandler { - Class[] participants() default {}; - - String comment() default ""; - - boolean defaultHandler() default false; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 223]: Avoid coupling the sender of a request to its + * receiver by giving more than one object a chance to handle the request. Chain + * the receiving objects and pass the request along the chain until an object + * handles it. + *

+ * Chain Of Responsibility Structure + * + * @author Heinz Kabutz + * @since 2010-07-28 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.BEHAVIORAL, + related = {CompositePattern.class}) +public @interface ChainOfResponsibilityPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Handler { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteHandler { + Class[] participants() default {}; + + String comment() default ""; + + boolean defaultHandler() default false; + } +} diff --git a/src/main/java/org/jpatterns/gof/CommandPattern.java b/src/main/java/org/jpatterns/gof/CommandPattern.java index 950f9c1..1dce962 100644 --- a/src/main/java/org/jpatterns/gof/CommandPattern.java +++ b/src/main/java/org/jpatterns/gof/CommandPattern.java @@ -1,81 +1,88 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 233]: Encapsulate a request as an object, thereby - * letting you parameterize clients with different requests, queue or log - * requests, and support undoable operations. - *

- * - * - * @author Michael Hunger - * @since 2010-08-08 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(source = Source.GoF, - type = Type.BEHAVIORAL, - urls = {"http://en.wikipedia.org/wiki/Command_pattern", - "http://home.earthlink.net/~huston2/dp/command.html"}, - refactorings = { - Refactoring.ExtractParameterObject, - Refactoring.ExtractMethodObject}, - related = {CompositePattern.class, MementoPattern.class, - PrototypePattern.class}) - -public @interface CommandPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Command { - Class[] participants() default {}; - - String comment() default ""; - - boolean undoable() default false; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteCommand { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Invoker { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Receiver { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Client { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Refactoring; +import org.jpatterns.core.Source; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 233]: Encapsulate a request as an object, thereby + * letting you parameterize clients with different requests, queue or log + * requests, and support undoable operations. + *

+ * Command Structure + * + * @author Michael Hunger + * @since 2010-08-08 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(source = Source.GoF, + type = Type.BEHAVIORAL, + urls = {"http://en.wikipedia.org/wiki/Command_pattern", + "http://home.earthlink.net/~huston2/dp/command.html"}, + refactorings = { + Refactoring.ExtractParameterObject, + Refactoring.ExtractMethodObject}, + related = {CompositePattern.class, MementoPattern.class, + PrototypePattern.class}) + +public @interface CommandPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Command { + Class[] participants() default {}; + + String comment() default ""; + + boolean undoable() default false; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteCommand { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Invoker { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Receiver { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Client { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/CompositePattern.java b/src/main/java/org/jpatterns/gof/CompositePattern.java index cbbc9d6..2af0c58 100644 --- a/src/main/java/org/jpatterns/gof/CompositePattern.java +++ b/src/main/java/org/jpatterns/gof/CompositePattern.java @@ -1,54 +1,59 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 163]: Compose objects into tree structures to - * represent whole-part hierarchies. Composite lets clients treat individual - * objects and compositions of objects uniformly. - *

- * - * - * @author Heinz Kabutz - * @since 2010-07-28 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.STRUCTURAL, - related = {ChainOfResponsibilityPattern.class, DecoratorPattern.class, - FlyweightPattern.class, IteratorPattern.class, VisitorPattern.class}) -public @interface CompositePattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Component { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Leaf { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Composite { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 163]: Compose objects into tree structures to + * represent whole-part hierarchies. Composite lets clients treat individual + * objects and compositions of objects uniformly. + *

+ * Composite Structure + * + * @author Heinz Kabutz + * @since 2010-07-28 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.STRUCTURAL, + related = {ChainOfResponsibilityPattern.class, DecoratorPattern.class, + FlyweightPattern.class, IteratorPattern.class, VisitorPattern.class}) +public @interface CompositePattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Component { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Leaf { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Composite { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/DecoratorPattern.java b/src/main/java/org/jpatterns/gof/DecoratorPattern.java index 9e367cd..419ac4c 100644 --- a/src/main/java/org/jpatterns/gof/DecoratorPattern.java +++ b/src/main/java/org/jpatterns/gof/DecoratorPattern.java @@ -1,63 +1,68 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 175]: Attach additional responsibilities to an object - * dynamically. Decorators provide a flexible alternative to subclassing for - * extending functionality. - *

- * - * - * @author Heinz Kabutz - * @since 2010-08-09 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.STRUCTURAL, - related = {AdapterPattern.class, CompositePattern.class, - StrategyPattern.class}) -public @interface DecoratorPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Component { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Decorator { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteComponent { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteDecorator { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 175]: Attach additional responsibilities to an object + * dynamically. Decorators provide a flexible alternative to subclassing for + * extending functionality. + *

+ * Decorator Structure + * + * @author Heinz Kabutz + * @since 2010-08-09 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.STRUCTURAL, + related = {AdapterPattern.class, CompositePattern.class, + StrategyPattern.class}) +public @interface DecoratorPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Component { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Decorator { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteComponent { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteDecorator { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/FacadePattern.java b/src/main/java/org/jpatterns/gof/FacadePattern.java index 875cb09..94d70cf 100644 --- a/src/main/java/org/jpatterns/gof/FacadePattern.java +++ b/src/main/java/org/jpatterns/gof/FacadePattern.java @@ -1,27 +1,32 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 185]: Provide a unified interface to a set of - * interfaces in a subsystem. Facade defines a higher-level interface that makes - * the subsystem easier to use. - *

- * - * - * @author Heinz Kabutz - * @since 2010-07-28 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.STRUCTURAL, - related = {AbstractFactoryPattern.class, MediatorPattern.class, - SingletonPattern.class}) -public @interface FacadePattern { - Class[] participants() default {}; - - String comment() default ""; -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 185]: Provide a unified interface to a set of + * interfaces in a subsystem. Facade defines a higher-level interface that makes + * the subsystem easier to use. + *

+ * Facade Structure + * + * @author Heinz Kabutz + * @since 2010-07-28 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.STRUCTURAL, + related = {AbstractFactoryPattern.class, MediatorPattern.class, + SingletonPattern.class}) +public @interface FacadePattern { + Class[] participants() default {}; + + String comment() default ""; +} diff --git a/src/main/java/org/jpatterns/gof/FactoryMethodPattern.java b/src/main/java/org/jpatterns/gof/FactoryMethodPattern.java index 5be7c21..7ffcf97 100644 --- a/src/main/java/org/jpatterns/gof/FactoryMethodPattern.java +++ b/src/main/java/org/jpatterns/gof/FactoryMethodPattern.java @@ -1,66 +1,71 @@ -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 ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 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. + *

+ * Factory Method Structure + * + * @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 ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/FlyweightPattern.java b/src/main/java/org/jpatterns/gof/FlyweightPattern.java index b9fe6c9..75c00be 100644 --- a/src/main/java/org/jpatterns/gof/FlyweightPattern.java +++ b/src/main/java/org/jpatterns/gof/FlyweightPattern.java @@ -1,62 +1,67 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 195]: Use sharing to support large numbers of - * fine-grained objects efficiently. - *

- * - * - * @author Heinz Kabutz - * @since 2010-07-28 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.STRUCTURAL, - related = {CompositePattern.class, StatePattern.class, - StrategyPattern.class}) -public @interface FlyweightPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface FlyweightFactory { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Flyweight { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface UnsharedConcreteFlyweight { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteFlyweight { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 195]: Use sharing to support large numbers of + * fine-grained objects efficiently. + *

+ * Flyweight Structure + * + * @author Heinz Kabutz + * @since 2010-07-28 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.STRUCTURAL, + related = {CompositePattern.class, StatePattern.class, + StrategyPattern.class}) +public @interface FlyweightPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface FlyweightFactory { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Flyweight { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface UnsharedConcreteFlyweight { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteFlyweight { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/InterpreterPattern.java b/src/main/java/org/jpatterns/gof/InterpreterPattern.java index edffcff..bdc73ab 100644 --- a/src/main/java/org/jpatterns/gof/InterpreterPattern.java +++ b/src/main/java/org/jpatterns/gof/InterpreterPattern.java @@ -1,8 +1,13 @@ package org.jpatterns.gof; -import org.jpatterns.core.*; +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * Intent [GoF, pg 243]: Given a language, define a represention for its @@ -16,46 +21,46 @@ @Target(ElementType.TYPE) @Documented @DesignPattern(type = Type.BEHAVIORAL, - related = {CompositePattern.class, FlyweightPattern.class, - IteratorPattern.class, VisitorPattern.class}) + related = {CompositePattern.class, FlyweightPattern.class, + IteratorPattern.class, VisitorPattern.class}) public @interface InterpreterPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Context { Class[] participants() default {}; String comment() default ""; - } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface AbstractExpression { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Context { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface TerminalExpression { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface AbstractExpression { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface NonterminalExpression { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface TerminalExpression { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface NonterminalExpression { + Class[] participants() default {}; + + String comment() default ""; + } } diff --git a/src/main/java/org/jpatterns/gof/IteratorPattern.java b/src/main/java/org/jpatterns/gof/IteratorPattern.java index 9a12995..7966b39 100644 --- a/src/main/java/org/jpatterns/gof/IteratorPattern.java +++ b/src/main/java/org/jpatterns/gof/IteratorPattern.java @@ -1,62 +1,67 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 257]: Provide a way to access the elements of an - * aggregate object sequentially without exposing its underlying representation. - *

- * - * - * @author Heinz Kabutz - * @since 2010-08-09 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.BEHAVIORAL, - related = {CompositePattern.class, FactoryMethodPattern.class, - MementoPattern.class}) -public @interface IteratorPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Aggregate { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Iterator { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteAggregate { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteIterator { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 257]: Provide a way to access the elements of an + * aggregate object sequentially without exposing its underlying representation. + *

+ * Iterator Structure + * + * @author Heinz Kabutz + * @since 2010-08-09 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.BEHAVIORAL, + related = {CompositePattern.class, FactoryMethodPattern.class, + MementoPattern.class}) +public @interface IteratorPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Aggregate { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Iterator { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteAggregate { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteIterator { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/MediatorPattern.java b/src/main/java/org/jpatterns/gof/MediatorPattern.java index 904cbd9..6e00ac1 100644 --- a/src/main/java/org/jpatterns/gof/MediatorPattern.java +++ b/src/main/java/org/jpatterns/gof/MediatorPattern.java @@ -1,63 +1,68 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 273]: Define an object that encapsulates how a set of - * objects interact. Mediator promotes loose coupling by keeping objects from - * referring to each other explicitly, and it lets you vary their interaction - * independently. - *

- * - * - * @author Heinz Kabutz - * @since 2010-08-09 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.BEHAVIORAL, - related = {FacadePattern.class, ObserverPattern.class}) -public @interface MediatorPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Mediator { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Colleague { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteMediator { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteColleague { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 273]: Define an object that encapsulates how a set of + * objects interact. Mediator promotes loose coupling by keeping objects from + * referring to each other explicitly, and it lets you vary their interaction + * independently. + *

+ * Mediator Structure + * + * @author Heinz Kabutz + * @since 2010-08-09 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.BEHAVIORAL, + related = {FacadePattern.class, ObserverPattern.class}) +public @interface MediatorPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Mediator { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Colleague { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteMediator { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteColleague { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/MementoPattern.java b/src/main/java/org/jpatterns/gof/MementoPattern.java index c5418a9..f0607fa 100644 --- a/src/main/java/org/jpatterns/gof/MementoPattern.java +++ b/src/main/java/org/jpatterns/gof/MementoPattern.java @@ -1,15 +1,20 @@ package org.jpatterns.gof; -import org.jpatterns.core.*; +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * Intent [GoF, pg 283]: Without violating encapsulation, capture and * externalize an object's internal state so that the object can be restored to * this state later. - *

- * + *

+ * Memento Structure * * @author Heinz Kabutz * @since 2010-08-09 @@ -18,45 +23,45 @@ @Target(ElementType.TYPE) @Documented @DesignPattern(type = Type.BEHAVIORAL, - related = {FacadePattern.class, ObserverPattern.class}) + related = {FacadePattern.class, ObserverPattern.class}) public @interface MementoPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Originator { Class[] participants() default {}; String comment() default ""; - } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Memento { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Originator { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface MementoImpl { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Memento { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Caretaker { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface MementoImpl { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Caretaker { + Class[] participants() default {}; + + String comment() default ""; + } } diff --git a/src/main/java/org/jpatterns/gof/ObserverPattern.java b/src/main/java/org/jpatterns/gof/ObserverPattern.java index d33c3d7..26ce654 100644 --- a/src/main/java/org/jpatterns/gof/ObserverPattern.java +++ b/src/main/java/org/jpatterns/gof/ObserverPattern.java @@ -1,62 +1,67 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 293]: Define a one-to-many dependency between objects - * so that when one object changes state, all its dependents are notified and - * updated automatically. - *

- * - * - * @author Heinz Kabutz - * @since 2010-08-09 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.BEHAVIORAL, - related = {MediatorPattern.class, SingletonPattern.class}) -public @interface ObserverPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Observer { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Subject { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteObserver { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteSubject { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 293]: Define a one-to-many dependency between objects + * so that when one object changes state, all its dependents are notified and + * updated automatically. + *

+ * Observer Structure + * + * @author Heinz Kabutz + * @since 2010-08-09 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.BEHAVIORAL, + related = {MediatorPattern.class, SingletonPattern.class}) +public @interface ObserverPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Observer { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Subject { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteObserver { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteSubject { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/PrototypePattern.java b/src/main/java/org/jpatterns/gof/PrototypePattern.java index 42be9ed..1142da5 100644 --- a/src/main/java/org/jpatterns/gof/PrototypePattern.java +++ b/src/main/java/org/jpatterns/gof/PrototypePattern.java @@ -1,8 +1,13 @@ package org.jpatterns.gof; -import org.jpatterns.core.*; +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * Intent [GoF, pg 117]: Specify the kinds of objects to create using a @@ -15,37 +20,37 @@ @Target(ElementType.TYPE) @Documented @DesignPattern(type = Type.CREATIONAL, - related = {AbstractFactoryPattern.class, CompositePattern.class, - DecoratorPattern.class}) + related = {AbstractFactoryPattern.class, CompositePattern.class, + DecoratorPattern.class}) public @interface PrototypePattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Prototype { Class[] participants() default {}; String comment() default ""; - } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcretePrototype { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Prototype { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - @Documented - public @interface Operation { - Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcretePrototype { + Class[] participants() default {}; - String comment() default ""; - } + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @Documented + public @interface Operation { + Class[] participants() default {}; + + String comment() default ""; + } } diff --git a/src/main/java/org/jpatterns/gof/ProxyPattern.java b/src/main/java/org/jpatterns/gof/ProxyPattern.java index edbfe00..b2e395c 100644 --- a/src/main/java/org/jpatterns/gof/ProxyPattern.java +++ b/src/main/java/org/jpatterns/gof/ProxyPattern.java @@ -1,77 +1,82 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 207]: Provide a surrogate or placeholder for another - * object to control access to it. - *

- * - * - * @author Heinz Kabutz - * @since 2010-07-28 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.FIELD, - ElementType.LOCAL_VARIABLE}) -@Documented -@DesignPattern(type = Type.STRUCTURAL, - related = {AdapterPattern.class, DecoratorPattern.class}) -public @interface ProxyPattern { - Class[] participants() default {}; - - String comment() default ""; - - Variation variation() default Variation.STATIC_MANUAL; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Subject { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface RealSubject { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Proxy { - Class[] participants() default {}; - - String comment() default ""; - - Variation variation() default Variation.STATIC_MANUAL; - - Type type() default Type.UNDEFINED; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.TYPE, ElementType.FIELD, - ElementType.LOCAL_VARIABLE}) - @Documented - public @interface Client { - Class[] participants() default {}; - - String comment() default ""; - } - - public static enum Variation { - STATIC_MANUAL, STATIC_GENERATED, DYNAMIC - } - - public static enum Type { - UNDEFINED, VIRTUAL, REMOTE, PROTECTION - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 207]: Provide a surrogate or placeholder for another + * object to control access to it. + *

+ * Proxy Structure + * + * @author Heinz Kabutz + * @since 2010-07-28 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD, + ElementType.LOCAL_VARIABLE}) +@Documented +@DesignPattern(type = Type.STRUCTURAL, + related = {AdapterPattern.class, DecoratorPattern.class}) +public @interface ProxyPattern { + Class[] participants() default {}; + + String comment() default ""; + + Variation variation() default Variation.STATIC_MANUAL; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Subject { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface RealSubject { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Proxy { + Class[] participants() default {}; + + String comment() default ""; + + Variation variation() default Variation.STATIC_MANUAL; + + Type type() default Type.UNDEFINED; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.TYPE, ElementType.FIELD, + ElementType.LOCAL_VARIABLE}) + @Documented + public @interface Client { + Class[] participants() default {}; + + String comment() default ""; + } + + public static enum Variation { + STATIC_MANUAL, STATIC_GENERATED, DYNAMIC + } + + public static enum Type { + UNDEFINED, VIRTUAL, REMOTE, PROTECTION + } +} diff --git a/src/main/java/org/jpatterns/gof/SingletonPattern.java b/src/main/java/org/jpatterns/gof/SingletonPattern.java index 99c3505..7b3b8f4 100644 --- a/src/main/java/org/jpatterns/gof/SingletonPattern.java +++ b/src/main/java/org/jpatterns/gof/SingletonPattern.java @@ -1,50 +1,55 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 127]: Ensure a class only has one instance, and - * provide a global point of access to it. - *

- * - * - * @author Alex Gout - * @since 2010-08-08 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.CREATIONAL, - related = {AbstractFactoryPattern.class, BuilderPattern.class, - PrototypePattern.class}) -public @interface SingletonPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Singleton { - Class[] participants() default {}; - - String comment() default ""; - - Variation variation() default Variation.LAZY; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - @Documented - public @interface SingletonMethod { - Class[] participants() default {}; - - String comment() default ""; - } - - public enum Variation { - LAZY, EAGER - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 127]: Ensure a class only has one instance, and + * provide a global point of access to it. + *

+ * Singleton Structure + * + * @author Alex Gout + * @since 2010-08-08 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.CREATIONAL, + related = {AbstractFactoryPattern.class, BuilderPattern.class, + PrototypePattern.class}) +public @interface SingletonPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Singleton { + Class[] participants() default {}; + + String comment() default ""; + + Variation variation() default Variation.LAZY; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @Documented + public @interface SingletonMethod { + Class[] participants() default {}; + + String comment() default ""; + } + + public enum Variation { + LAZY, EAGER + } +} diff --git a/src/main/java/org/jpatterns/gof/StatePattern.java b/src/main/java/org/jpatterns/gof/StatePattern.java index 68e033e..173cfde 100644 --- a/src/main/java/org/jpatterns/gof/StatePattern.java +++ b/src/main/java/org/jpatterns/gof/StatePattern.java @@ -1,52 +1,57 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 305]: Allow an object to alter its behavior when its - * internal state changes. The object will appear to change its class. - *

- * - * - * @author Heinz Kabutz - * @since 2010-08-09 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.BEHAVIORAL, - related = {FlyweightPattern.class, SingletonPattern.class}) -public @interface StatePattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Context { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface State { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteState { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 305]: Allow an object to alter its behavior when its + * internal state changes. The object will appear to change its class. + *

+ * State Structure + * + * @author Heinz Kabutz + * @since 2010-08-09 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.BEHAVIORAL, + related = {FlyweightPattern.class, SingletonPattern.class}) +public @interface StatePattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Context { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface State { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteState { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/StrategyPattern.java b/src/main/java/org/jpatterns/gof/StrategyPattern.java index b4675ff..ac7e6a1 100644 --- a/src/main/java/org/jpatterns/gof/StrategyPattern.java +++ b/src/main/java/org/jpatterns/gof/StrategyPattern.java @@ -1,62 +1,67 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 315]: Define a family of algorithms, encapsulate each - * one, and make them interchangeable. Strategy lets the algorithm vary - * independently from clients that use it. - *

- * - * - * @author Heinz Kabutz - * @since 2010-07-28 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.BEHAVIORAL, - related = {FlyweightPattern.class}) -public @interface StrategyPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Context { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Strategy { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @Documented - public @interface StrategyField { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteStrategy { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 315]: Define a family of algorithms, encapsulate each + * one, and make them interchangeable. Strategy lets the algorithm vary + * independently from clients that use it. + *

+ * Strategy Structure + * + * @author Heinz Kabutz + * @since 2010-07-28 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.BEHAVIORAL, + related = {FlyweightPattern.class}) +public @interface StrategyPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Context { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Strategy { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.FIELD) + @Documented + public @interface StrategyField { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteStrategy { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/TemplateMethodPattern.java b/src/main/java/org/jpatterns/gof/TemplateMethodPattern.java index 9497187..8fb921a 100644 --- a/src/main/java/org/jpatterns/gof/TemplateMethodPattern.java +++ b/src/main/java/org/jpatterns/gof/TemplateMethodPattern.java @@ -1,77 +1,82 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 325]: Define the skeleton of an algorithm in an - * operation, deferring some steps to subclasses. Template Method lets - * subclasses redefine certain steps of an algorithm without changing the - * algorithm's structure. - *

- * - * - * @author Heinz Kabutz - * @since 2010-07-28 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.METHOD}) -@Documented -@DesignPattern(type = Type.BEHAVIORAL, - related = {FactoryMethodPattern.class, StrategyPattern.class}) -public @interface TemplateMethodPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface AbstractClass { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteClass { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - @Documented - public @interface TemplateMethod { - Class[] participants() default {}; - - String comment() default ""; - } - - - /** - * @deprecated Misnamed, please use @PrimitiveOperation instead. - */ - @Deprecated - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - @Documented - public @interface PrimitiveMethod { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - @Documented - public @interface PrimitiveOperation { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 325]: Define the skeleton of an algorithm in an + * operation, deferring some steps to subclasses. Template Method lets + * subclasses redefine certain steps of an algorithm without changing the + * algorithm's structure. + *

+ * Template Method Structure + * + * @author Heinz Kabutz + * @since 2010-07-28 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD}) +@Documented +@DesignPattern(type = Type.BEHAVIORAL, + related = {FactoryMethodPattern.class, StrategyPattern.class}) +public @interface TemplateMethodPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface AbstractClass { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteClass { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @Documented + public @interface TemplateMethod { + Class[] participants() default {}; + + String comment() default ""; + } + + + /** + * @deprecated Misnamed, please use @PrimitiveOperation instead. + */ + @Deprecated + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @Documented + public @interface PrimitiveMethod { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @Documented + public @interface PrimitiveOperation { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/gof/VisitorPattern.java b/src/main/java/org/jpatterns/gof/VisitorPattern.java index 5d5b599..2ba7e5b 100644 --- a/src/main/java/org/jpatterns/gof/VisitorPattern.java +++ b/src/main/java/org/jpatterns/gof/VisitorPattern.java @@ -1,71 +1,76 @@ -package org.jpatterns.gof; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [GoF, pg 331]: Represent an operation to be performed on the - * elements of an object structure. Visitor lets you define a new operation - * without changing the classes of the elements on which it operates. - *

- * - * - * @author Heinz Kabutz - * @since 2010-08-09 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(type = Type.BEHAVIORAL, - related = {CompositePattern.class, InterpreterPattern.class}) -public @interface VisitorPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Visitor { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteVisitor { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Element { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ConcreteElement { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface ObjectStructure { - Class[] participants() default {}; - - String comment() default ""; - } -} +package org.jpatterns.gof; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [GoF, pg 331]: Represent an operation to be performed on the + * elements of an object structure. Visitor lets you define a new operation + * without changing the classes of the elements on which it operates. + *

+ * Visitor Structure + * + * @author Heinz Kabutz + * @since 2010-08-09 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(type = Type.BEHAVIORAL, + related = {CompositePattern.class, InterpreterPattern.class}) +public @interface VisitorPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Visitor { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteVisitor { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Element { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ConcreteElement { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface ObjectStructure { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/jee/BusinessDelegatePattern.java b/src/main/java/org/jpatterns/jee/BusinessDelegatePattern.java index 9c41d91..bec78ca 100644 --- a/src/main/java/org/jpatterns/jee/BusinessDelegatePattern.java +++ b/src/main/java/org/jpatterns/jee/BusinessDelegatePattern.java @@ -1,53 +1,58 @@ -/** - * - */ -package org.jpatterns.jee; - -import org.jpatterns.core.*; -import org.jpatterns.gof.AdapterPattern.Adapter; -import org.jpatterns.gof.FacadePattern; - -import java.lang.annotation.*; - -/** - * Intent [Core J2EE Patterns, pg 249]: use a BusinessDelegate to reduce - * coupling between presentation-tier clients and business services. The - * BusinessDelegate hides the underlying implementation details of the business - * service [...]. - *

- * - *

- * - * @author Marco Tedone - * @since 2010-08-21 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -@Documented -@DesignPattern(source = Source.CoreJ2EE, type = Type.ENTERPRISE, - related = {Adapter.class, FacadePattern.class}) -public @interface BusinessDelegatePattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.TYPE, ElementType.FIELD, ElementType.LOCAL_VARIABLE, - ElementType.PARAMETER}) - @Documented - public @interface BusinessDelegate { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.TYPE, ElementType.FIELD, ElementType.LOCAL_VARIABLE, - ElementType.PARAMETER}) - @Documented - public @interface BusinessService { - Class[] participants() default {}; - - String comment() default ""; - } -} +/** + * + */ +package org.jpatterns.jee; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Source; +import org.jpatterns.core.Type; +import org.jpatterns.gof.AdapterPattern.Adapter; +import org.jpatterns.gof.FacadePattern; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [Core J2EE Patterns, pg 249]: use a BusinessDelegate to reduce + * coupling between presentation-tier clients and business services. The + * BusinessDelegate hides the underlying implementation details of the business + * service [...]. + *

+ * Business Delegate Structure + * + * @author Marco Tedone + * @since 2010-08-21 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +@Documented +@DesignPattern(source = Source.CoreJ2EE, type = Type.ENTERPRISE, + related = {Adapter.class, FacadePattern.class}) +public @interface BusinessDelegatePattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.TYPE, ElementType.FIELD, ElementType.LOCAL_VARIABLE, + ElementType.PARAMETER}) + @Documented + public @interface BusinessDelegate { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.TYPE, ElementType.FIELD, ElementType.LOCAL_VARIABLE, + ElementType.PARAMETER}) + @Documented + public @interface BusinessService { + Class[] participants() default {}; + + String comment() default ""; + } +} diff --git a/src/main/java/org/jpatterns/jee/DataAccessObjectPattern.java b/src/main/java/org/jpatterns/jee/DataAccessObjectPattern.java index da7c5ae..a4508c4 100644 --- a/src/main/java/org/jpatterns/jee/DataAccessObjectPattern.java +++ b/src/main/java/org/jpatterns/jee/DataAccessObjectPattern.java @@ -1,81 +1,86 @@ -/** - * - */ -package org.jpatterns.jee; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent [Core J2EE Patterns, pg 391]: Abstract and encapsulate all - * access to the data source. The DAO manages the connection with the data - * source to obtain and store data - *

- * - *

- * - * @author Marco Tedone - * @since 2010-08-19 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@DesignPattern(source = Source.CoreJ2EE, - type = Type.ENTERPRISE) -public @interface DataAccessObjectPattern { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.TYPE, ElementType.FIELD, - ElementType.LOCAL_VARIABLE, ElementType.PARAMETER}) - @Documented - public @interface BusinessObject { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.TYPE, ElementType.FIELD, - ElementType.LOCAL_VARIABLE, ElementType.PARAMETER}) - @Documented - public @interface Dao { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.TYPE, ElementType.FIELD, - ElementType.LOCAL_VARIABLE, ElementType.PARAMETER}) - @Documented - public @interface DataSource { - Class[] participants() default {}; - - String comment() default ""; - - // Giving users the possibility to specify which datasource they are using - // might be useful for maintainance. The information is optional anyway - - DataSourceType dataSourceType() default DataSourceType.UNDEFINED; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.TYPE, ElementType.FIELD, - ElementType.LOCAL_VARIABLE, ElementType.PARAMETER}) - @Documented - public @interface ValueObject { - Class[] participants() default {}; - - String comment() default ""; - } - - public enum DataSourceType { - HIBERNATE, SPRING, ORACLE, DB2, MYSQL, SQLSERVER, SYBASE, BERKELEY, - UNDEFINED - } - -} +/** + * + */ +package org.jpatterns.jee; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Source; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent [Core J2EE Patterns, pg 391]: Abstract and encapsulate all + * access to the data source. The DAO manages the connection with the data + * source to obtain and store data + *

+ * DAO Structure + * + * @author Marco Tedone + * @since 2010-08-19 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@DesignPattern(source = Source.CoreJ2EE, + type = Type.ENTERPRISE) +public @interface DataAccessObjectPattern { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.TYPE, ElementType.FIELD, + ElementType.LOCAL_VARIABLE, ElementType.PARAMETER}) + @Documented + public @interface BusinessObject { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.TYPE, ElementType.FIELD, + ElementType.LOCAL_VARIABLE, ElementType.PARAMETER}) + @Documented + public @interface Dao { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.TYPE, ElementType.FIELD, + ElementType.LOCAL_VARIABLE, ElementType.PARAMETER}) + @Documented + public @interface DataSource { + Class[] participants() default {}; + + String comment() default ""; + + // Giving users the possibility to specify which datasource they are using + // might be useful for maintainance. The information is optional anyway + + DataSourceType dataSourceType() default DataSourceType.UNDEFINED; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.TYPE, ElementType.FIELD, + ElementType.LOCAL_VARIABLE, ElementType.PARAMETER}) + @Documented + public @interface ValueObject { + Class[] participants() default {}; + + String comment() default ""; + } + + public enum DataSourceType { + HIBERNATE, SPRING, ORACLE, DB2, MYSQL, SQLSERVER, SYBASE, BERKELEY, + UNDEFINED + } + +} diff --git a/src/main/java/org/jpatterns/jee/ModelViewController.java b/src/main/java/org/jpatterns/jee/ModelViewController.java index 4e3b071..1d61d18 100644 --- a/src/main/java/org/jpatterns/jee/ModelViewController.java +++ b/src/main/java/org/jpatterns/jee/ModelViewController.java @@ -1,61 +1,66 @@ -package org.jpatterns.jee; - -import org.jpatterns.core.*; - -import java.lang.annotation.*; - -/** - * Intent: The Model View Controller (MVC) pattern divides an application in - * three components: The View, the Controller and the Model. - *

- *

- * - *

- * - * @author Marco Tedone - * @since 2010-08-21 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -@Documented -@DesignPattern(source = Source.Other, - type = Type.ENTERPRISE) -public @interface ModelViewController { - Class[] participants() default {}; - - String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface View { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Controller { - Class[] participants() default {}; - - String comment() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface Model { - Class[] participants() default {}; - - String comment() default ""; - } +package org.jpatterns.jee; + +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Source; +import org.jpatterns.core.Type; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Intent: The Model View Controller (MVC) pattern divides an application in + * three components: The View, the Controller and the Model. + *

+ *

+ * Mediator Structure + * + * @author Marco Tedone + * @since 2010-08-21 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +@Documented +@DesignPattern(source = Source.Other, + type = Type.ENTERPRISE) +public @interface ModelViewController { + Class[] participants() default {}; + + String comment() default ""; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface View { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Controller { + Class[] participants() default {}; + + String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface Model { + Class[] participants() default {}; + + String comment() default ""; + } } \ No newline at end of file diff --git a/src/main/java/org/jpatterns/jee/package-info.java b/src/main/java/org/jpatterns/jee/package-info.java index 866b0d1..c779517 100644 --- a/src/main/java/org/jpatterns/jee/package-info.java +++ b/src/main/java/org/jpatterns/jee/package-info.java @@ -1,13 +1,12 @@ -/** - * This file contains {@link org.jpatterns.core.Type#ENTERPRISE} patterns as - * described in the CORE J2EE Patterns 2nd Edition - Best Practices and Design - * Strategies book. - * - *

- * Although some of the EE patterns described in this book are obsolete, - * others are still actual and defined in this package. - * - * @author Marco Tedone - * @since 2010-08-19 - */ +/** + * This file contains {@link org.jpatterns.core.Type#ENTERPRISE} patterns as + * described in the CORE J2EE Patterns 2nd Edition - Best Practices and Design + * Strategies book. + *

+ * Although some of the EE patterns described in this book are obsolete, + * others are still actual and defined in this package. + * + * @author Marco Tedone + * @since 2010-08-19 + */ package org.jpatterns.jee; \ No newline at end of file diff --git a/src/main/java/org/jpatterns/plopd/NullObjectPattern.java b/src/main/java/org/jpatterns/plopd/NullObjectPattern.java index ad413eb..21abe02 100644 --- a/src/main/java/org/jpatterns/plopd/NullObjectPattern.java +++ b/src/main/java/org/jpatterns/plopd/NullObjectPattern.java @@ -1,9 +1,17 @@ package org.jpatterns.plopd; -import org.jpatterns.core.*; -import org.jpatterns.gof.*; +import org.jpatterns.core.DesignPattern; +import org.jpatterns.core.Source; +import org.jpatterns.core.Type; +import org.jpatterns.gof.FlyweightPattern; +import org.jpatterns.gof.SingletonPattern; +import org.jpatterns.gof.StrategyPattern; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * Intent [PLoPD3, pg 5]: A Null Object provides a surrogate for another @@ -16,52 +24,52 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.FIELD, - ElementType.LOCAL_VARIABLE}) + ElementType.LOCAL_VARIABLE}) @Documented @DesignPattern( - source = Source.PLoPD3, - type = Type.BEHAVIORAL, - related = {FlyweightPattern.class, StrategyPattern.class, - SingletonPattern.class}) + source = Source.PLoPD3, + type = Type.BEHAVIORAL, + related = {FlyweightPattern.class, StrategyPattern.class, + SingletonPattern.class}) public @interface NullObjectPattern { - public abstract Class[] participants() default {}; - - public abstract String comment() default ""; - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface AbstractObject { public abstract Class[] participants() default {}; public abstract String comment() default ""; - } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface RealObject { - public abstract Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface AbstractObject { + public abstract Class[] participants() default {}; - public abstract String comment() default ""; - } + public abstract String comment() default ""; + } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - @Documented - public @interface NullObject { - public abstract Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface RealObject { + public abstract Class[] participants() default {}; - public abstract String comment() default ""; - } + public abstract String comment() default ""; + } - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.TYPE, ElementType.FIELD, - ElementType.LOCAL_VARIABLE}) - @Documented - public @interface Client { - public abstract Class[] participants() default {}; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + @Documented + public @interface NullObject { + public abstract Class[] participants() default {}; - public abstract String comment() default ""; - } + public abstract String comment() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.TYPE, ElementType.FIELD, + ElementType.LOCAL_VARIABLE}) + @Documented + public @interface Client { + public abstract Class[] participants() default {}; + + public abstract String comment() default ""; + } }