[weld-commits] Weld SVN: r6381 - extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Jun 2 17:44:20 EDT 2010


Author: shane.bryzak at jboss.com
Date: 2010-06-02 17:44:18 -0400 (Wed, 02 Jun 2010)
New Revision: 6381

Added:
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AnnotatedPropertyCriteria.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/BeanPropertyCriteria.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/BeanPropertyQuery.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/NamedPropertyCriteria.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypedPropertyCriteria.java
Removed:
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AbstractBeanProperty.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AnnotatedBeanProperty.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Properties.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypeAnnotatedBeanProperty.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypedBeanProperty.java
Modified:
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/FieldProperty.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/MethodProperty.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Property.java
Log:
redesign bean property utils

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AbstractBeanProperty.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AbstractBeanProperty.java	2010-06-02 19:00:02 UTC (rev 6380)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AbstractBeanProperty.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -1,112 +0,0 @@
-package org.jboss.weld.extensions.util.properties;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-/**
- * Base class for bean property wrappers. Non-deterministic in the case their
- * are multiple annotated properties.
- * 
- * Threadsafe.
- * 
- * @author Shane Bryzak
- */
-public class AbstractBeanProperty<V>
-{
-
-   static class Matched<T>
-   {
-      
-      private T matched;
-
-      void setMatched(T matched)
-      {
-         this.matched = matched;
-      }
-      
-      T getMatched()
-      {
-         return matched;
-      }
-      
-   }
-
-   /**
-    * Subclasses should provide an implementation of FieldMatcher to determine
-    * whether a Field contains the bean property
-    */
-   static interface FieldMatcher
-   {
-      boolean matches(Field field);
-   }
-
-   /**
-    * Subclasses should provide an implementation of MethodMatcher to determine
-    * whether a method provides the bean property
-    */
-   static interface MethodMatcher
-   {
-      boolean matches(Method method);
-   }
-
-   /**
-    * Property field
-    */
-   private final Property<V> property;
-
-   /**
-    * 
-    * @param targetClass
-    */
-   public AbstractBeanProperty(Class<?> targetClass, FieldMatcher fieldMatcher, MethodMatcher methodMatcher)
-   {
-
-      // First check declared fields
-      for (Field field : targetClass.getDeclaredFields())
-      {
-         if (fieldMatcher.matches(field))
-         {
-            this.property = Properties.createProperty(field);
-            return;
-         }
-      }
-
-      // Then check public fields, in case it's inherited
-      for (Field field : targetClass.getFields())
-      {
-         if (fieldMatcher.matches(field))
-         {
-            this.property = Properties.createProperty(field);
-            return;
-         }
-      }
-
-      // Then check public methods (we ignore private methods)
-      for (Method method : targetClass.getMethods())
-      {
-         if (methodMatcher.matches(method))
-         {
-            this.property = Properties.createProperty(method);
-            return;
-         }
-      }
-      this.property = null;
-   }
-
-   /**
-    * Returns true if the property has been successfully located, otherwise
-    * returns false.
-    * 
-    * @return
-    */
-   public boolean exists()
-   {
-      return property != null;
-   }
-
-   public Property<V> getProperty()
-   {
-      return property;
-   }
-
-}

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AnnotatedBeanProperty.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AnnotatedBeanProperty.java	2010-06-02 19:00:02 UTC (rev 6380)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AnnotatedBeanProperty.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -1,63 +0,0 @@
-package org.jboss.weld.extensions.util.properties;
-
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-
-/**
- * A convenience class for working with an annotated property (either a field or
- * method) of a JavaBean class.
- * 
- * @author Shane Bryzak
- * @author Pete Muir
- */
-public class AnnotatedBeanProperty<V> extends AbstractBeanProperty<V>
-{
-
-   /**
-    * An {@link AnnotatedElement} based matcher
-    * 
-    * @author pmuir
-    * 
-    */
-   public interface AnnotationMatcher
-   {
-      boolean matches(AnnotatedElement element);
-   }
-
-   private static class AnnotationMatcherAdapter implements FieldMatcher, MethodMatcher
-   {
-      private final AnnotationMatcher matcher;
-
-      public AnnotationMatcherAdapter(AnnotationMatcher matcher)
-      {
-         if (matcher == null)
-         {
-            throw new IllegalArgumentException("matcher must not be null");
-         }
-         this.matcher = matcher;
-      }
-
-      public boolean matches(Field f)
-      {
-         return matcher.matches(f);
-      }
-
-      public boolean matches(Method m)
-      {
-         return matcher.matches(m);
-      }
-   }
-   
-   public AnnotatedBeanProperty(Class<?> targetClass, AnnotationMatcher annotationMatcher)
-   {
-      this(targetClass, new AnnotationMatcherAdapter(annotationMatcher));
-   }
-   
-   private AnnotatedBeanProperty(Class<?> targetClass, AnnotationMatcherAdapter matcher)
-   {
-      super(targetClass, matcher, matcher);
-   }
-
-}
\ No newline at end of file

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AnnotatedPropertyCriteria.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AnnotatedPropertyCriteria.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/AnnotatedPropertyCriteria.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -0,0 +1,31 @@
+package org.jboss.weld.extensions.util.properties;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * A criteria that matches a property based on its annotations
+ * 
+ * @author Shane Bryzak
+ */
+public class AnnotatedPropertyCriteria implements BeanPropertyCriteria
+{
+   private Class<? extends Annotation> annotationClass;
+   
+   public AnnotatedPropertyCriteria(Class<? extends Annotation> annotationClass)
+   {
+      this.annotationClass = annotationClass;
+   }
+   
+   public boolean fieldMatches(Field f)
+   {
+      return f.isAnnotationPresent(annotationClass);
+   }
+
+   public boolean methodMatches(Method m)
+   {
+      return m.isAnnotationPresent(annotationClass);
+   }
+
+}

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/BeanPropertyCriteria.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/BeanPropertyCriteria.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/BeanPropertyCriteria.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -0,0 +1,28 @@
+package org.jboss.weld.extensions.util.properties;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * Base interface for criteria used to locate bean properties
+ * 
+ * @author Shane Bryzak
+ */
+public interface BeanPropertyCriteria
+{
+   /**
+    * Tests whether the specified field matches the criteria
+    * 
+    * @param f
+    * @return true if the field matches
+    */
+   boolean fieldMatches(Field f);
+   
+   /**
+    * Tests whether the specified method matches the criteria
+    * 
+    * @param m
+    * @return true if the method matches
+    */
+   boolean methodMatches(Method m);
+}

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/BeanPropertyQuery.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/BeanPropertyQuery.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/BeanPropertyQuery.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -0,0 +1,65 @@
+package org.jboss.weld.extensions.util.properties;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Queries a target class for properties that match certain criteria
+ * 
+ * @author Shane Bryzak
+ */
+public class BeanPropertyQuery
+{
+   private Class<?> targetClass;
+   private List<BeanPropertyCriteria> criteria = new ArrayList<BeanPropertyCriteria>();
+   
+   public BeanPropertyQuery(Class<?> targetClass)
+   {
+      this.targetClass = targetClass;
+   }
+   
+   public BeanPropertyQuery addCriteria(BeanPropertyCriteria criteria)
+   {
+      this.criteria.add(criteria);
+      return this;
+   }
+   
+   public List<Property> getResultList()
+   {
+      List<Property> results = new ArrayList<Property>();
+
+      Class<?> cls = targetClass;
+      while (!cls.equals(Object.class))
+      {
+         // First check declared fields
+         for (Field field : cls.getDeclaredFields())
+         {
+            for (BeanPropertyCriteria c : criteria)
+            {                     
+               if (c.fieldMatches(field))
+               {
+                  results.add(new FieldProperty(field));
+               }
+            }
+         }
+         
+         cls = cls.getSuperclass();
+      }
+
+      // Then check public methods (we ignore private methods)
+      for (Method method : targetClass.getMethods())
+      {
+         for (BeanPropertyCriteria c : criteria)
+         {
+            if (c.methodMatches(method))
+            {
+               results.add(new MethodProperty(method));
+            }
+         }
+      }      
+      
+      return results;
+   }
+}

Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/FieldProperty.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/FieldProperty.java	2010-06-02 19:00:02 UTC (rev 6380)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/FieldProperty.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -3,13 +3,19 @@
  */
 package org.jboss.weld.extensions.util.properties;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Type;
 
-class FieldProperty<V> implements Property<V>
+/**
+ * A bean property based on the value contained in a field
+ * 
+ * @author Pete Muir
+ * @author Shane Bryzak
+ *
+ */
+class FieldProperty implements Property
 {
-   
-
    private static String buildGetFieldValueErrorMessage(Field field, Object obj)
    {
       return String.format("Exception reading [%s] field from object [%s].", field.getName(), obj);
@@ -22,7 +28,7 @@
    
    private final Field field;
 
-   FieldProperty(Field field)
+   public FieldProperty(Field field)
    {
       this.field = field;
    }
@@ -37,23 +43,22 @@
       return field.getGenericType();
    }
    
-   public Field getAnnotatedElement()
+   public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
    {
-      return field;
+      return field.getAnnotation(annotationClass);
    }
    
-   @SuppressWarnings("unchecked")
-   public Class<V> getJavaClass()
+   public Class<?> getPropertyClass()
    {
-      return (Class<V>) field.getType();
+      return (Class<?>) field.getType();
    }
    
-   public V getValue(Object instance)
+   public Object getValue(Object instance)
    {
       field.setAccessible(true);
       try
       {
-         return getJavaClass().cast(field.get(instance));
+         return getPropertyClass().cast(field.get(instance));
       }
       catch (IllegalAccessException e)
       {
@@ -67,7 +72,7 @@
       }
    }
    
-   public void setValue(Object instance, V value) 
+   public void setValue(Object instance, Object value) 
    {
       field.setAccessible(true);
       try

Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/MethodProperty.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/MethodProperty.java	2010-06-02 19:00:02 UTC (rev 6380)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/MethodProperty.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -4,13 +4,71 @@
 package org.jboss.weld.extensions.util.properties;
 
 import java.beans.Introspector;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 
-class MethodProperty<V> implements Property<V>
-{
+/**
+ * A bean property based on the value represented by a getter/setter method pair
+ * 
+ * @author Pete Muir
+ * @author Shane Bryzak
+ */
+class MethodProperty implements Property
+{   
+   private final Method getterMethod;
+   private final String propertyName;
+   private final Method setterMethod;
+
+   public MethodProperty(Method method)
+   {
+      if (method.getName().startsWith("get"))
+      {
+         this.propertyName = Introspector.decapitalize(method.getName().substring(3));
+      }
+      else if (method.getName().startsWith("is"))
+      {
+         this.propertyName = Introspector.decapitalize(method.getName().substring(2));
+      }
+      else
+      {
+         throw new IllegalArgumentException("Invalid accessor method, must start with 'get' or 'is'.  " + "Method: " + method);
+      }
+      this.getterMethod = getGetterMethod(method.getDeclaringClass(), propertyName);
+      this.setterMethod = getSetterMethod(method.getDeclaringClass(), propertyName);      
+   }
    
+   public String getName()
+   {
+      return propertyName;
+   }
+   
+   public Class<?> getPropertyClass()
+   {
+      return getterMethod.getReturnType();
+   }
+   
+   public Type getBaseType()
+   {
+      return getterMethod.getGenericReturnType();
+   }
+   
+   public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
+   {
+      return getterMethod.getAnnotation(annotationClass);
+   }
+   
+   public Object getValue(Object instance)
+   {
+      return getPropertyClass().cast(invokeMethod(getterMethod, instance));
+   }
+   
+   public void setValue(Object instance, Object value) 
+   {
+      invokeMethod(setterMethod, instance, value);
+   }
+   
    private static String buildInvokeMethodErrorMessage(Method method, Object obj, Object... args)
    {
       StringBuilder message = new StringBuilder(String.format("Exception invoking method [%s] on object [%s], using arguments [", method.getName(), obj));
@@ -92,60 +150,5 @@
          }
       }
       throw new IllegalArgumentException("no such getter method: " + clazz.getName() + '.' + name);
-   }
-   
-   private final Method getterMethod;
-   private final String propertyName;
-   private final Method setterMethod;
-
-   MethodProperty(Method method)
-   {
-      if (method.getName().startsWith("get"))
-      {
-         this.propertyName = Introspector.decapitalize(method.getName().substring(3));
-      }
-      else if (method.getName().startsWith("is"))
-      {
-         this.propertyName = Introspector.decapitalize(method.getName().substring(2));
-      }
-      else
-      {
-         throw new IllegalArgumentException("Invalid accessor method, must start with 'get' or 'is'.  " + "Method: " + method);
-      }
-      this.getterMethod = getGetterMethod(method.getDeclaringClass(), propertyName);
-      this.setterMethod = getSetterMethod(method.getDeclaringClass(), propertyName);
-      
-   }
-   
-   public String getName()
-   {
-      return propertyName;
-   }
-   
-   @SuppressWarnings("unchecked")
-   public Class<V> getJavaClass()
-   {
-      return (Class<V>) getterMethod.getReturnType();
-   }
-   
-   public Type getBaseType()
-   {
-      return getterMethod.getGenericReturnType();
-   }
-   
-   public Method getAnnotatedElement()
-   {
-      return getterMethod;
-   }
-   
-   public V getValue(Object instance)
-   {
-      return getJavaClass().cast(invokeMethod(getterMethod, instance));
-   }
-   
-   public void setValue(Object instance, V value) 
-   {
-      invokeMethod(setterMethod, instance, value);
-   }
-   
+   }   
 }
\ No newline at end of file

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/NamedPropertyCriteria.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/NamedPropertyCriteria.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/NamedPropertyCriteria.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -0,0 +1,31 @@
+package org.jboss.weld.extensions.util.properties;
+
+import java.beans.Introspector;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * A criteria that matches a property based on name
+ * 
+ * @author Shane Bryzak
+ */
+public class NamedPropertyCriteria implements BeanPropertyCriteria
+{
+   private String propertyName;
+   
+   public NamedPropertyCriteria(String propertyName)
+   {
+      this.propertyName = propertyName;
+   }
+   
+   public boolean fieldMatches(Field f)
+   {
+      return propertyName.equals(f.getName());
+   }
+
+   public boolean methodMatches(Method m)
+   {
+      return m.getName().startsWith("get") && 
+         Introspector.decapitalize(m.getName().substring(3)).equals(propertyName);
+   }
+}

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Properties.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Properties.java	2010-06-02 19:00:02 UTC (rev 6380)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Properties.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -1,42 +0,0 @@
-package org.jboss.weld.extensions.util.properties;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-/**
- * Utility class for working with JavaBean style properties
- * 
- * @author pmuir
- *
- */
-public class Properties
-{
-   
-   private Properties() {}
- 
-   /**
-    * Create a JavaBean style property from the field
-    * 
-    * @param <V>
-    * @param field
-    * @return
-    */
-   public static <V> Property<V> createProperty(Field field)
-   {
-      return new FieldProperty<V>(field);
-   }
-   
-   /**
-    * Create a JavaBean style property from the specified method
-    * 
-    * @param <V>
-    * @param method
-    * @return
-    * @throws IllegalArgumentException if the method does not match JavaBean conventions
-    */
-   public static <V> Property<V> createProperty(Method method)
-   {
-      return new MethodProperty<V>(method);
-   }
-
-}

Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Property.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Property.java	2010-06-02 19:00:02 UTC (rev 6380)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Property.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -1,6 +1,6 @@
 package org.jboss.weld.extensions.util.properties;
 
-import java.lang.reflect.AnnotatedElement;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
 /**
@@ -9,10 +9,11 @@
  * @see Properties
  * 
  * @author pmuir
+ * @author Shane Bryzak
  *
  * @param <V>
  */
-public interface Property<V>
+public interface Property
 {
    
    /**
@@ -23,23 +24,30 @@
     * 
     * @return The name of the property
     */
-   public String getName();
+   String getName();
    
    /**
     * Returns the property type
     * 
     * @return The property type
     */
-   public Type getBaseType();
+   Type getBaseType();
    
    /**
     * Returns the property type
     * 
     * @return The property type
     */
-   public Class<V> getJavaClass();
+   Class<?> getPropertyClass();   
    
-   public AnnotatedElement getAnnotatedElement();
+   /**
+    * Returns the specified annotation, if it exists on the bean property
+    * 
+    * @param <A>
+    * @param annotationClass
+    * @return
+    */
+   <A extends Annotation> A getAnnotation(Class<A> annotationClass);
    
    /**
     * Returns the property value for the specified bean. The property to be
@@ -48,7 +56,7 @@
     * @param bean The bean to read the property from
     * @return The property value
     */
-   public V getValue(Object instance);
+    Object getValue(Object instance);
    
    /**
     * This method sets the property value for a specified bean to the specified
@@ -57,6 +65,5 @@
     * @param bean The bean containing the property to set
     * @param value The new property value
     */
-   public void setValue(Object instance, V value);
-   
+   void setValue(Object instance, Object value);   
 }
\ No newline at end of file

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypeAnnotatedBeanProperty.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypeAnnotatedBeanProperty.java	2010-06-02 19:00:02 UTC (rev 6380)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypeAnnotatedBeanProperty.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -1,72 +0,0 @@
-package org.jboss.weld.extensions.util.properties;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-
-public class TypeAnnotatedBeanProperty<T extends Annotation, V> extends AnnotatedBeanProperty<V>
-{
-
-   
-   /**
-    * An AnnotationMatcher which simply requires the the annotation to be of the
-    * specified type
-    * 
-    */
-   private static class TypeAnnotationMatcher<T extends Annotation> implements AnnotationMatcher
-   {
-
-      private final Class<T> annotationType;
-      
-      private final Matched<T> matched; 
-
-      public TypeAnnotationMatcher(Class<T> annotationType, Matched<T> matched)
-      {
-         if (annotationType == null)
-         {
-            throw new IllegalArgumentException("annotationType must not be null");
-         }
-         this.annotationType = annotationType;
-         this.matched = matched;
-      }
-
-      public boolean matches(AnnotatedElement element)
-      {
-         if (element.isAnnotationPresent(annotationType))
-         {
-            this.matched.setMatched(element.getAnnotation(annotationType));
-            return true;
-         }
-         else
-         {
-            return false;
-         }
-      }
-   }
-   
-   private final T annotation;
-
-   /**
-    * Default constructor
-    * 
-    * @param cls The class to scan for the property
-    * @param annotationClass The annotation class to scan for. Specified
-    *           attribute values may be scanned for by providing an
-    *           implementation of the isMatch() method.
-    */
-   public TypeAnnotatedBeanProperty(Class<?> cls, Class<T> annotationType)
-   {
-      this(cls, annotationType, new Matched<T>());
-   }
-   
-   private TypeAnnotatedBeanProperty(Class<?> targetClass, Class<T> annotationType, Matched<T> matched)
-   {
-      super(targetClass, new TypeAnnotationMatcher<T>(annotationType, matched));
-      this.annotation = matched.getMatched();
-   }
-   
-   public T getAnnotation()
-   {
-      return annotation;
-   }
-
-}

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypedBeanProperty.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypedBeanProperty.java	2010-06-02 19:00:02 UTC (rev 6380)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypedBeanProperty.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -1,44 +0,0 @@
-package org.jboss.weld.extensions.util.properties;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-
-/**
- * A convenience class for working with a typed property (either a field or
- * method) of a JavaBean class.
- * 
- * @author Shane Bryzak
- */
-public class TypedBeanProperty<V> extends AbstractBeanProperty<V>
-{   
-   private static class TypedMatcher<V> implements FieldMatcher, MethodMatcher
-   {
-      private Class<V> propertyClass;
-      
-      public TypedMatcher(Class<V> propertyClass)
-      {
-         if (propertyClass == null)
-         {
-            throw new IllegalArgumentException("propertyClass can not be null.");
-         }
-         
-         this.propertyClass = propertyClass;
-      }
-      
-      public boolean matches(Field f)
-      {
-         return propertyClass.equals(f.getType());
-      }      
-      
-      public boolean matches(Method m)
-      {
-         return propertyClass.equals(m.getReturnType());
-      }        
-   }
-   
-   public TypedBeanProperty(Class<?> targetClass, Class<V> propertyClass)
-   {            
-      super(targetClass, new TypedMatcher<V>(propertyClass), new TypedMatcher<V>(propertyClass));
-   }
-}

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypedPropertyCriteria.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypedPropertyCriteria.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/TypedPropertyCriteria.java	2010-06-02 21:44:18 UTC (rev 6381)
@@ -0,0 +1,29 @@
+package org.jboss.weld.extensions.util.properties;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * A criteria that matches a property based on its type
+ * 
+ * @author Shane Bryzak
+ */
+public class TypedPropertyCriteria implements BeanPropertyCriteria
+{
+   private Class<?> propertyClass;
+   
+   public TypedPropertyCriteria(Class<?> propertyClass)
+   {
+      this.propertyClass = propertyClass;
+   }
+
+   public boolean fieldMatches(Field f)
+   {
+      return propertyClass.equals(f.getType());
+   }
+
+   public boolean methodMatches(Method m)
+   {
+      return propertyClass.equals(m.getReturnType());
+   }
+}



More information about the weld-commits mailing list