DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=33353>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=33353 Summary: add collection modifiers feature to PropertyUtilsBean. Product: Commons Version: unspecified Platform: PC OS/Version: Windows XP Status: NEW Severity: enhancement Priority: P2 Component: Bean Utilities AssignedTo: commons-dev@jakarta.apache.org ReportedBy: [EMAIL PROTECTED] There's some java beans who are not lazy ones and who need to modify collection type properties. Ongoing propertyUtilsBean only allows to set indexed property, but not to add or remove items in collection. This is a proposition to add following new features : - propertyUtilsBean.(add | remove )CollectionPropertyValue(Object bean, String name, Object value) Action: (add to | remove from ) bean property name a value. In other words, search a method (add | remove)item(parameterType value) where parameterType.isAssignable(value.class) to add value to item collection, item collection bean property being deduced with a stemmer algo (as in betwixt.DefaultPluralStemmer) from method name and declared by getProperty(bean,name).getClass(); Sample : myPropertyUtilsBean.addCollectionPropertyValue(myBean, "productMap("food").catalog.products", new Product("acmeDogFood", 12)); will use Catalog.addProduct(Product p) to add new Product("acmeDogFood", 12) to inner collection Catalog.products. - PropertyUtilsBean.(add | remove )CollectionPropertyValue(Object bean, String property, String itemName, Object value) Action: (add to | remove from ) bean property name a value. In other words, search a method (add | remove)item(parameterType value) where parameterType.isAssignable(value.class) to add value to item collection, item collection being deduced with a stemmer algo (as in betwixt.DefaultPluralStemmer) from itemName and declared by getProperty(bean,name).getClass(); Sample : myPropertyUtilsBean.addCollectionPropertyValue(myBean, "productMap("food").catalog","product", new Product("acmeDogFood", 12)); will use Catalog.addProduct(Product p) to add new Product("acmeDogFood", 12) to inner Catalog.productList. If there's no Catalog.addProduct(Product p) method, try to invoke Collection.add(Object obj) on Catalog.products. I have yet created in PropertyUtilsBean sub class such feature as demonstrator and unit tests work (for the meantime). Constraints: - Object are to apply java beans specification. - Collection must have readable method ( to be considered as bean property) - adder and remover method have to follow conventions copied from org.apache.commons.betwixt.strategy.DefaultPluralStemmer Matching select in this order for an given itemName or a deduced from method name one: 1. get itemName+"s" :("items") 2. if ( itemName ends with "y" ) 1. get itemName+"es" (no sample, my english is too poor !) 2. get substitute itemName ending with "ies" ("baby" => "babies") 3. get itemName + "List" 4. get itemName + "Set" 5. get itemName + "Collection 6. Browse propertyMap to get a property starting with itemName, as "itemBag". If there's several property matching later, select the longuest property name : "itemBagCollection" instead of "itemBag" - method selection : If two methods match this upper requirements (name (add | remove)Item(ParmType value) and parameterType.isAssignable(value.class)) , first method matching is selected. Methods are ordered following min "distance" metric : - "Distance" metric is the base on public int getDistance(Class c) { Class superclass = c.getSuperclass(); int distance = 0; while ( superclass != null ) { superclass = superclass.getSuperclass(); distance ++; } return distance; } -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]