Commits

Michael Ludwig committed d1b866a

Move @Named and @SharedInstance annotation into property package.

Comments (0)

Files changed (14)

entreri-apt-tests/src/it/InvalidSharedObjectComponent/src/main/java/InvalidSharedObjectComponent.java

 package com.lhkbob.entreri.components;
 
 import com.lhkbob.entreri.Component;
-import com.lhkbob.entreri.SharedInstance;
+import com.lhkbob.entreri.property.SharedInstance;
 
 /**
  * Invalid component definition that double checks that we fail when using a shared

entreri-apt-tests/src/it/InvalidSharedPrimitiveComponent/src/main/java/InvalidSharedPrimitiveComponent.java

 package com.lhkbob.entreri.components;
 
 import com.lhkbob.entreri.Component;
-import com.lhkbob.entreri.SharedInstance;
+import com.lhkbob.entreri.property.SharedInstance;
 
 /**
  * Invalid component type that tries to have a shared instance from a property that

entreri-apt-tests/src/it/MismatchedNameComponent/src/main/java/MismatchedNameComponent.java

 package com.lhkbob.entreri.components;
 
 import com.lhkbob.entreri.Component;
-import com.lhkbob.entreri.Named;
+import com.lhkbob.entreri.property.Named;
 
 /**
  * A component type that uses mismatched Named annotations to break an otherwise valid

entreri-apt-tests/src/main/java/com.lhkbob.entreri.components/ComplexComponent.java

  */
 package com.lhkbob.entreri.components;
 
-import com.lhkbob.entreri.Named;
-import com.lhkbob.entreri.SharedInstance;
 import com.lhkbob.entreri.property.Factory;
 import com.lhkbob.entreri.property.IntProperty.DefaultInt;
 import com.lhkbob.entreri.property.LongProperty.DefaultLong;
+import com.lhkbob.entreri.property.Named;
+import com.lhkbob.entreri.property.SharedInstance;
 
 /**
  * A Component that tests a variety of things: multiple properties, different types,

entreri-core/src/main/java/com/lhkbob/entreri/Component.java

  * <p/>
  * Logically a component definition is a set of named and typed properties, and a
  * method-based API to get and set the values of each property. Specific types of
- * component are defined by creating a sub-interface of Component. Using the {@link Named}
- * {@link SharedInstance}, {@link com.lhkbob.entreri.property.Factory Factory} and custom
+ * component are defined by creating a sub-interface of Component. Using the {@link
+ * com.lhkbob.entreri.property.Named @Named} {@link com.lhkbob.entreri.property.SharedInstance
+ *
+ * @author Michael Ludwig
+ * @SharedInstance}, {@link com.lhkbob.entreri.property.Factory @Factory} and custom
  * {@link com.lhkbob.entreri.property.Attribute Attribute} annotations defined by {@link
  * com.lhkbob.entreri.property.Property Property} implementations, the data properties of
  * the component type are specified in the sub-interface. A declaration model similar to
  * <ol> <li>Non-void, zero-argument methods starting with 'get', 'is', and 'has' declare a
  * property. The property type is inspected from the return type of the method. The
  * property name is the method name minus the 'get'/'is'/'has' prefix with its first
- * letter made lower-case. The {@link Named} annotation can be used to override the
- * name.</li> <li>Single-argument methods starting with 'set' are assumed to be a setter
- * corresponding to a property. The single parameter's type must equal the type the
- * getter. The {@link Named} annotation can be applied to either the setter or the
- * parameter to specify the property name.</li> <li>Multi-argument methods starting with
- * 'set' are assumed to be a setter that assigns values to multiple property, one for each
- * argument. Each argument must be annotated with {@link Named} to specify the property,
- * and the argument type must equal the type of the matching property.</li> <li>Setter
- * methods must return void or return the components type, in which case the proxy will
- * return itself to allow for method chaining.</li> <li>Getters with void return types or
- * more than 0 arguments, setters with an invalid return type or no arguments, and any
- * other method not matching the conventions above will cause the system to throw an
- * {@link IllegalComponentDefinitionException}.</li> </ol>
+ * letter made lower-case. The {@link com.lhkbob.entreri.property.Named @Named} annotation
+ * can be used to override the name.</li> <li>Single-argument methods starting with 'set'
+ * are assumed to be a setter corresponding to a property. The single parameter's type
+ * must equal the type the getter. The {@link com.lhkbob.entreri.property.Named @Named}
+ * annotation can be applied to either the setter or the parameter to specify the property
+ * name.</li> <li>Multi-argument methods starting with 'set' are assumed to be a setter
+ * that assigns values to multiple property, one for each argument. Each argument must be
+ * annotated with {@link com.lhkbob.entreri.property.Named @Named} to specify the
+ * property, and the argument type must equal the type of the matching property.</li>
+ * <li>Setter methods must return void or return the components type, in which case the
+ * proxy will return itself to allow for method chaining.</li> <li>Getters with void
+ * return types or more than 0 arguments, setters with an invalid return type or no
+ * arguments, and any other method not matching the conventions above will cause the
+ * system to throw an {@link IllegalComponentDefinitionException}.</li> </ol>
  * <p/>
  * Internally, the entity system will generate proxy implementations of the component
  * interfaces that implement the property getters and setters but store all of the values
  * in {@link com.lhkbob.entreri.property.Property} instances of a compatible type. This
  * allows iteration over components to have much better cache locality if the component is
  * defined in terms of primitives or types that have specialized Property implementations
- * that can pack and unpack an instance. The {@link SharedInstance} annotation can be
- * added to the getter method of a property to specify that the {@link
- * com.lhkbob.entreri.property.ShareableProperty ShareableProperty} API should be
- * leveraged by the generated class.
+ * that can pack and unpack an instance. The {@link com.lhkbob.entreri.property.SharedInstance
+ * @SharedInstance} annotation can be added to the getter method of a property to specify
+ * that the {@link com.lhkbob.entreri.property.ShareableProperty ShareableProperty} API
+ * should be leveraged by the generated class.
  * <p/>
  * Additional attribute annotations can be added to the getter method to influence the
  * behavior of the {@link com.lhkbob.entreri.property.PropertyFactory PropertyFactory}
  * <p/>
  * Attribute annotations provided by the default property implementations are outlined
  * below: <ul> <li>{@link com.lhkbob.entreri.property.BooleanProperty.DefaultBoolean
- *
- * @author Michael Ludwig
  * @DefaultBoolean} - set value for boolean properties</li> <li>{@link
  * com.lhkbob.entreri.property.ByteProperty.DefaultByte @DefaultByte} - set value for byte
  * properties</li> <li>{@link com.lhkbob.entreri.property.ShortProperty.DefaultShort

entreri-core/src/main/java/com/lhkbob/entreri/Named.java

-/*
- * Entreri, an entity-component framework in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.lhkbob.entreri;
-
-import java.lang.annotation.*;
-
-/**
- * Annotation applied to getters, setters, and setter parameters in a Component definition
- * to specify an exact property name instead of using Java naming conventions to infer it
- * from the getter or setter.
- * <p/>
- * When a setter takes multiple parameters, this annotation is required for each parameter
- * because method parameter names are not always available via reflection at runtime.
- *
- * @author Michael Ludwig
- * @see Component
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.PARAMETER, ElementType.METHOD })
-public @interface Named {
-    /**
-     * @return The property name
-     */
-    String value();
-}

entreri-core/src/main/java/com/lhkbob/entreri/SharedInstance.java

-/*
- * Entreri, an entity-component framework in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.lhkbob.entreri;
-
-import java.lang.annotation.*;
-
-/**
- * SharedInstance is used to annotate Component getters when the Component instance
- * returns the same object regardless of how the component's identity changes. This can
- * only be used on properties whose type can be handled by a {@link
- * com.lhkbob.entreri.property.ShareableProperty} class.
- *
- * @author Michael Ludwig
- */
-@Documented
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface SharedInstance {
-
-}

entreri-core/src/main/java/com/lhkbob/entreri/impl/PropertyDeclaration.java

 public interface PropertyDeclaration extends Comparable<PropertyDeclaration> {
     /**
      * Get the logical name of the property, either the name extracted from the getter
-     * bean method, or from the {@link com.lhkbob.entreri.Named} annotation.
+     * bean method, or from the {@link com.lhkbob.entreri.property.Named} annotation.
      *
      * @return The property name
      */
      * Get whether or not this property should use the shared instance API to store and
      * get values of the property.
      *
-     * @return True if the getter was annotated with {@link com.lhkbob.entreri.SharedInstance}
+     * @return True if the getter was annotated with {@link com.lhkbob.entreri.property.SharedInstance}
      */
     public boolean isShared();
 

entreri-core/src/main/java/com/lhkbob/entreri/property/Named.java

+/*
+ * Entreri, an entity-component framework in Java
+ *
+ * Copyright (c) 2012, Michael Ludwig
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ *     Redistributions of source code must retain the above copyright notice,
+ *         this list of conditions and the following disclaimer.
+ *     Redistributions in binary form must reproduce the above copyright notice,
+ *         this list of conditions and the following disclaimer in the
+ *         documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.lhkbob.entreri.property;
+
+import java.lang.annotation.*;
+
+/**
+ * Annotation applied to getters, setters, and setter parameters in a Component definition
+ * to specify an exact property name instead of using Java naming conventions to infer it
+ * from the getter or setter.
+ * <p/>
+ * When a setter takes multiple parameters, this annotation is required for each parameter
+ * because method parameter names are not always available via reflection at runtime.
+ *
+ * @author Michael Ludwig
+ * @see com.lhkbob.entreri.Component
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.PARAMETER, ElementType.METHOD })
+public @interface Named {
+    /**
+     * @return The property name
+     */
+    String value();
+}

entreri-core/src/main/java/com/lhkbob/entreri/property/SharedInstance.java

+/*
+ * Entreri, an entity-component framework in Java
+ *
+ * Copyright (c) 2012, Michael Ludwig
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ *     Redistributions of source code must retain the above copyright notice,
+ *         this list of conditions and the following disclaimer.
+ *     Redistributions in binary form must reproduce the above copyright notice,
+ *         this list of conditions and the following disclaimer in the
+ *         documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.lhkbob.entreri.property;
+
+import java.lang.annotation.*;
+
+/**
+ * SharedInstance is used to annotate Component getters when the Component instance
+ * returns the same object regardless of how the component's identity changes. This can
+ * only be used on properties whose type can be handled by a {@link
+ * com.lhkbob.entreri.property.ShareableProperty} class.
+ *
+ * @author Michael Ludwig
+ */
+@Documented
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface SharedInstance {
+
+}

entreri-core/src/test/java/com/lhkbob/entreri/components/ComplexComponent.java

  */
 package com.lhkbob.entreri.components;
 
-import com.lhkbob.entreri.Named;
-import com.lhkbob.entreri.SharedInstance;
 import com.lhkbob.entreri.property.Factory;
 import com.lhkbob.entreri.property.IntProperty.DefaultInt;
 import com.lhkbob.entreri.property.LongProperty.DefaultLong;
+import com.lhkbob.entreri.property.Named;
+import com.lhkbob.entreri.property.SharedInstance;
 
 /**
  * A Component that tests a variety of things: multiple properties, different types,

entreri-core/src/test/java/com/lhkbob/entreri/components/InvalidSharedObjectComponent.java

 package com.lhkbob.entreri.components;
 
 import com.lhkbob.entreri.Component;
-import com.lhkbob.entreri.SharedInstance;
+import com.lhkbob.entreri.property.SharedInstance;
 
 /**
  * Invalid component definition that double checks that we fail when using a shared

entreri-core/src/test/java/com/lhkbob/entreri/components/InvalidSharedPrimitiveComponent.java

 package com.lhkbob.entreri.components;
 
 import com.lhkbob.entreri.Component;
-import com.lhkbob.entreri.SharedInstance;
+import com.lhkbob.entreri.property.SharedInstance;
 
 /**
  * Invalid component type that tries to have a shared instance from a property that

entreri-core/src/test/java/com/lhkbob/entreri/components/MismatchedNameComponent.java

 package com.lhkbob.entreri.components;
 
 import com.lhkbob.entreri.Component;
-import com.lhkbob.entreri.Named;
+import com.lhkbob.entreri.property.Named;
 
 /**
  * A component type that uses mismatched Named annotations to break an otherwise valid