[weld-commits] Weld SVN: r6388 - in extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties: query and 1 other directory.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Wed Jun 2 18:43:34 EDT 2010
Author: pete.muir at jboss.org
Date: 2010-06-02 18:43:33 -0400 (Wed, 02 Jun 2010)
New Revision: 6388
Added:
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/PropertyQuery.java
Removed:
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/BeanPropertyCriteria.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/BeanPropertyQuery.java
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Property.java
Log:
rename
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 22:39:08 UTC (rev 6387)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Property.java 2010-06-02 22:43:33 UTC (rev 6388)
@@ -53,6 +53,7 @@
*
* @param bean The bean to read the property from
* @return The property value
+ * @throws ClassCastException if the value is not of the type V
*/
public V getValue(Object instance);
Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/BeanPropertyCriteria.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/BeanPropertyCriteria.java 2010-06-02 22:39:08 UTC (rev 6387)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/BeanPropertyCriteria.java 2010-06-02 22:43:33 UTC (rev 6388)
@@ -1,28 +0,0 @@
-package org.jboss.weld.extensions.util.properties.query;
-
-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);
-}
Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/BeanPropertyQuery.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/BeanPropertyQuery.java 2010-06-02 22:39:08 UTC (rev 6387)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/BeanPropertyQuery.java 2010-06-02 22:43:33 UTC (rev 6388)
@@ -1,68 +0,0 @@
-package org.jboss.weld.extensions.util.properties.query;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.weld.extensions.util.properties.Properties;
-import org.jboss.weld.extensions.util.properties.Property;
-
-/**
- * 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(Properties.createProperty(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(Properties.createProperty(method));
- }
- }
- }
-
- return results;
- }
-}
Copied: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/PropertyQuery.java (from rev 6386, extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/BeanPropertyQuery.java)
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/PropertyQuery.java (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/PropertyQuery.java 2010-06-02 22:43:33 UTC (rev 6388)
@@ -0,0 +1,69 @@
+package org.jboss.weld.extensions.util.properties.query;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.weld.extensions.util.properties.Properties;
+import org.jboss.weld.extensions.util.properties.Property;
+
+/**
+ * Queries a target class for properties that match certain criteria
+ *
+ * @author Shane Bryzak
+ */
+public class PropertyQuery<V>
+{
+ private final Class<?> targetClass;
+ private final List<PropertyCriteria> criteria;
+
+ public PropertyQuery(Class<?> targetClass)
+ {
+ this.targetClass = targetClass;
+ this.criteria = new ArrayList<PropertyCriteria>();
+ }
+
+ public PropertyQuery<V> addCriteria(PropertyCriteria criteria)
+ {
+ this.criteria.add(criteria);
+ return this;
+ }
+
+ public List<Property<V>> getResultList()
+ {
+ List<Property<V>> results = new ArrayList<Property<V>>();
+
+ Class<?> cls = targetClass;
+ while (!cls.equals(Object.class))
+ {
+ // First check declared fields
+ for (Field field : cls.getDeclaredFields())
+ {
+ for (PropertyCriteria c : criteria)
+ {
+ if (c.fieldMatches(field))
+ {
+ results.add(Properties.<V>createProperty(field));
+ }
+ }
+ }
+
+ cls = cls.getSuperclass();
+ }
+
+ // Then check public methods (we ignore private methods)
+ for (Method method : targetClass.getMethods())
+ {
+ for (PropertyCriteria c : criteria)
+ {
+ if (c.methodMatches(method))
+ {
+ results.add(Properties.<V>createProperty(method));
+ }
+ }
+ }
+
+ return results;
+ }
+}
More information about the weld-commits
mailing list