commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <j...@apache.org>
Subject [jira] Updated: (BEANUTILS-188) [beanutils] add collection modifiers feature to PropertyUtilsBean
Date Tue, 22 May 2007 00:43:16 GMT

     [ https://issues.apache.org/jira/browse/BEANUTILS-188?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Niall Pemberton updated BEANUTILS-188:
--------------------------------------

    Fix Version/s:     (was: 1.8.0)
                   LATER THAN 1.8.0

> [beanutils] add collection modifiers feature to PropertyUtilsBean
> -----------------------------------------------------------------
>
>                 Key: BEANUTILS-188
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-188
>             Project: Commons BeanUtils
>          Issue Type: Improvement
>          Components: Bean / Property Utils
>         Environment: Operating System: All
> Platform: All
>            Reporter: Marc DeXeT
>            Priority: Minor
>             Fix For: LATER THAN 1.8.0
>
>
> 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;
>             }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message