Weld SVN: r6383 - extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties.
by weld-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-06-02 18:20:02 -0400 (Wed, 02 Jun 2010)
New Revision: 6383
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/BeanPropertyQuery.java
Log:
minor
Modified: 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 2010-06-02 22:18:50 UTC (rev 6382)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/BeanPropertyQuery.java 2010-06-02 22:20:02 UTC (rev 6383)
@@ -26,9 +26,9 @@
return this;
}
- public List<Property> getResultList()
+ public List<Property<?>> getResultList()
{
- List<Property> results = new ArrayList<Property>();
+ List<Property<?>> results = new ArrayList<Property<?>>();
Class<?> cls = targetClass;
while (!cls.equals(Object.class))
@@ -40,7 +40,7 @@
{
if (c.fieldMatches(field))
{
- results.add(new FieldProperty(field));
+ results.add(Properties.createProperty(field));
}
}
}
@@ -55,7 +55,7 @@
{
if (c.methodMatches(method))
{
- results.add(new MethodProperty(method));
+ results.add(Properties.createProperty(method));
}
}
}
14 years, 7 months
Weld SVN: r6382 - extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties.
by weld-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-06-02 18:18:50 -0400 (Wed, 02 Jun 2010)
New Revision: 6382
Added:
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Properties.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:
rollback a few changes
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 21:44:18 UTC (rev 6381)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/FieldProperty.java 2010-06-02 22:18:50 UTC (rev 6382)
@@ -14,7 +14,7 @@
* @author Shane Bryzak
*
*/
-class FieldProperty implements Property
+class FieldProperty<V> implements Property<V>
{
private static String buildGetFieldValueErrorMessage(Field field, Object obj)
{
@@ -28,7 +28,7 @@
private final Field field;
- public FieldProperty(Field field)
+ FieldProperty(Field field)
{
this.field = field;
}
@@ -48,17 +48,18 @@
return field.getAnnotation(annotationClass);
}
- public Class<?> getPropertyClass()
+ @SuppressWarnings("unchecked")
+ public Class<V> getJavaClass()
{
- return (Class<?>) field.getType();
+ return (Class<V>) field.getType();
}
- public Object getValue(Object instance)
+ public V getValue(Object instance)
{
field.setAccessible(true);
try
{
- return getPropertyClass().cast(field.get(instance));
+ return getJavaClass().cast(field.get(instance));
}
catch (IllegalAccessException e)
{
@@ -72,7 +73,7 @@
}
}
- public void setValue(Object instance, Object value)
+ public void setValue(Object instance, V 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 21:44:18 UTC (rev 6381)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/MethodProperty.java 2010-06-02 22:18:50 UTC (rev 6382)
@@ -15,7 +15,7 @@
* @author Pete Muir
* @author Shane Bryzak
*/
-class MethodProperty implements Property
+class MethodProperty<V> implements Property<V>
{
private final Method getterMethod;
private final String propertyName;
@@ -44,9 +44,10 @@
return propertyName;
}
- public Class<?> getPropertyClass()
+ @SuppressWarnings("unchecked")
+ public Class<V> getJavaClass()
{
- return getterMethod.getReturnType();
+ return (Class<V>) getterMethod.getReturnType();
}
public Type getBaseType()
@@ -59,9 +60,9 @@
return getterMethod.getAnnotation(annotationClass);
}
- public Object getValue(Object instance)
+ public V getValue(Object instance)
{
- return getPropertyClass().cast(invokeMethod(getterMethod, instance));
+ return getJavaClass().cast(invokeMethod(getterMethod, instance));
}
public void setValue(Object instance, Object value)
Added: 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 (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Properties.java 2010-06-02 22:18:50 UTC (rev 6382)
@@ -0,0 +1,41 @@
+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 21:44:18 UTC (rev 6381)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/Property.java 2010-06-02 22:18:50 UTC (rev 6382)
@@ -13,7 +13,7 @@
*
* @param <V>
*/
-public interface Property
+public interface Property<V>
{
/**
@@ -38,7 +38,7 @@
*
* @return The property type
*/
- Class<?> getPropertyClass();
+ Class<V> getJavaClass();
/**
* Returns the specified annotation, if it exists on the bean property
@@ -56,7 +56,7 @@
* @param bean The bean to read the property from
* @return The property value
*/
- Object getValue(Object instance);
+ V getValue(Object instance);
/**
* This method sets the property value for a specified bean to the specified
@@ -65,5 +65,5 @@
* @param bean The bean containing the property to set
* @param value The new property value
*/
- void setValue(Object instance, Object value);
+ void setValue(Object instance, V value);
}
\ No newline at end of file
14 years, 7 months
Weld SVN: r6381 - extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties.
by weld-commits@lists.jboss.org
Author: shane.bryzak(a)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());
+ }
+}
14 years, 7 months
Weld SVN: r6380 - core/trunk/inject-tck-runner.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-06-02 15:00:02 -0400 (Wed, 02 Jun 2010)
New Revision: 6380
Modified:
core/trunk/inject-tck-runner/pom.xml
Log:
minor
Modified: core/trunk/inject-tck-runner/pom.xml
===================================================================
--- core/trunk/inject-tck-runner/pom.xml 2010-06-02 15:39:57 UTC (rev 6379)
+++ core/trunk/inject-tck-runner/pom.xml 2010-06-02 19:00:02 UTC (rev 6380)
@@ -89,6 +89,17 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
14 years, 7 months
Weld SVN: r6379 - build/trunk/dist-tck/porting-package.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-06-02 11:39:57 -0400 (Wed, 02 Jun 2010)
New Revision: 6379
Modified:
build/trunk/dist-tck/porting-package/pom.xml
Log:
minor
Modified: build/trunk/dist-tck/porting-package/pom.xml
===================================================================
--- build/trunk/dist-tck/porting-package/pom.xml 2010-06-02 15:22:00 UTC (rev 6378)
+++ build/trunk/dist-tck/porting-package/pom.xml 2010-06-02 15:39:57 UTC (rev 6379)
@@ -12,10 +12,6 @@
<packaging>pom</packaging>
<name>JSR-299 TCK Distribution - Weld Porting Package</name>
- <properties>
- <weld.version>1.0.0-SNAPSHOT</weld.version>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.jboss.weld</groupId>
@@ -47,7 +43,7 @@
<optional>true</optional>
<scope>compile</scope>
<type>test-jar</type>
- <classifier>sources</classifier>
+ <classifier>test-sources</classifier>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
14 years, 7 months
Weld SVN: r6378 - core/trunk/bom.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-06-02 11:22:00 -0400 (Wed, 02 Jun 2010)
New Revision: 6378
Modified:
core/trunk/bom/pom.xml
Log:
there is no relative path
Modified: core/trunk/bom/pom.xml
===================================================================
--- core/trunk/bom/pom.xml 2010-06-02 15:21:49 UTC (rev 6377)
+++ core/trunk/bom/pom.xml 2010-06-02 15:22:00 UTC (rev 6378)
@@ -8,7 +8,8 @@
<parent>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-parent</artifactId>
- <version>10</version>
+ <version>11</version>
+ <relativePath />
</parent>
<name>Weld Core BOM</name>
14 years, 7 months
Weld SVN: r6377 - api/trunk/bom.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-06-02 11:21:49 -0400 (Wed, 02 Jun 2010)
New Revision: 6377
Modified:
api/trunk/bom/pom.xml
Log:
there is no relative path
Modified: api/trunk/bom/pom.xml
===================================================================
--- api/trunk/bom/pom.xml 2010-06-02 12:47:43 UTC (rev 6376)
+++ api/trunk/bom/pom.xml 2010-06-02 15:21:49 UTC (rev 6377)
@@ -8,7 +8,7 @@
<parent>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-parent</artifactId>
- <version>10</version>
+ <version>11</version>
</parent>
<name>Weld and CDI APIs BOM</name>
14 years, 7 months
Weld SVN: r6375 - build/tags.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-06-02 08:47:35 -0400 (Wed, 02 Jun 2010)
New Revision: 6375
Added:
build/tags/weld-parent-11/
Log:
[maven-scm] copy for tag weld-parent-11
Copied: build/tags/weld-parent-11 (from rev 6374, build/trunk/parent)
14 years, 7 months