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

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Jun 3 22:13:59 EDT 2010


Author: shane.bryzak at jboss.com
Date: 2010-06-03 22:13:58 -0400 (Thu, 03 Jun 2010)
New Revision: 6402

Modified:
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/NamedPropertyCriteria.java
Log:
support for multiple possible property names

Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/NamedPropertyCriteria.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/NamedPropertyCriteria.java	2010-06-03 15:56:17 UTC (rev 6401)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/properties/query/NamedPropertyCriteria.java	2010-06-04 02:13:58 UTC (rev 6402)
@@ -11,21 +11,30 @@
  */
 public class NamedPropertyCriteria implements PropertyCriteria
 {
-   private final String propertyName;
+   private final String[] propertyNames;
    
-   public NamedPropertyCriteria(String propertyName)
+   public NamedPropertyCriteria(String... propertyNames)
    {
-      this.propertyName = propertyName;
+      this.propertyNames = propertyNames;
    }
    
    public boolean fieldMatches(Field f)
    {
-      return propertyName.equals(f.getName());
+      for (String propertyName : propertyNames)
+      {
+         if (propertyName.equals(f.getName())) return true;
+      }
+      return false;
    }
 
    public boolean methodMatches(Method m)
    {
-      return m.getName().startsWith("get") && 
-         Introspector.decapitalize(m.getName().substring(3)).equals(propertyName);
+      for (String propertyName : propertyNames)
+      {
+         if (m.getName().startsWith("get") && 
+            Introspector.decapitalize(m.getName().substring(3)).equals(propertyName)) return true;
+         
+      }
+      return false;
    }
 }



More information about the weld-commits mailing list