Commits

Michael Ludwig committed 308051c

Move entreri-mapping.properties files to the root of the package to make them a little more generic

Comments (0)

Files changed (5)

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

  * 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}
- * and {@link SharedInstance} annotations and specific conventions the data properties of
- * the component type are specified in the sub-interface. A declaration model similar to
- * the Java Bean model is used and is outlined below:
+ * {@link SharedInstance}, and {@link com.lhkbob.entreri.property.Factory} annotations and
+ * specific conventions the data properties of the component type are specified in the
+ * sub-interface. A declaration model similar to the Java Bean model is used and is
+ * outlined below:
  * <p/>
  * <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
  * <p/>
  * Additional attribute annotations can be added to the getter method to influence the
  * behavior of the {@link com.lhkbob.entreri.property.PropertyFactory} used for each
- * property in the component definition.
+ * property in the component definition. Besides using the Factory annotation to specify
+ * the factory type, libraries can specify a mapping file 'entreri-mapping.properties' at
+ * the root of their resource tree that contains key-value maps from a class type to
+ * Property implementation.
  * <p/>
  * The generated proxies will implement equals() and hashCode() based on their type and
  * the id of their owning entity. The {@link ComponentIterator} class creates flyweight

src/main/java/com/lhkbob/entreri/TypePropertyMapping.java

 
         // otherwise check if we have a properties file to load
         // FIXME this requires the type to be aware of the wrapping property impl
-        InputStream in = type.getResourceAsStream("entreri-mapping.properties");
+        InputStream in = type.getResourceAsStream("/entreri-mapping.properties");
         if (in != null) {
             Properties p = new Properties();
             try {

src/test/java/com/lhkbob/entreri/property/CustomProperty.java

 package com.lhkbob.entreri.property;
 
 @Factory(CustomProperty.CustomFactoryWithAttributes.class)
-public class CustomProperty implements ShareableProperty {
+public class CustomProperty implements ShareableProperty<CustomProperty.Bletch> {
     private final ObjectProperty<Bletch> property;
 
     public CustomProperty() {
         property.setDataStore(store);
     }
 
+    @Override
     public Bletch createShareableInstance() {
         return new Bletch();
     }
         return property.get(index);
     }
 
-    // FIXME might be wrong signature
+    @Override
     public void get(int index, Bletch b) {
         b.value = property.get(index).value;
     }
             b.value = (!attributes.hasAttribute(IntProperty.DefaultInt.class) ? 0
                                                                               : attributes
                                .getAttribute(IntProperty.DefaultInt.class).value());
-            property.property.set(b, index);
+            property.set(b, index);
         }
     }
 

src/test/resources/com/lhkbob/entreri/property/entreri-mapping.properties

-com.lhkbob.entreri.property.CustomProperty$Bletch=com.lhkbob.entreri.property.CustomProperty
-com.lhkbob.entreri.property.NoFactoryProperty$Crass=com.lhkbob.entreri.property.NoFactoryProperty

src/test/resources/entreri-mapping.properties

+com.lhkbob.entreri.property.CustomProperty$Bletch=com.lhkbob.entreri.property.CustomProperty
+com.lhkbob.entreri.property.NoFactoryProperty$Crass=com.lhkbob.entreri.property.NoFactoryProperty