English 中文(简体)
Operating On Collections
  • 时间:2024-12-22

Java BeanUtils - Operating On Collections


Previous Page Next Page  

Description

The Commons-Collections are build upon interfaces, implementations and utipties. It contains Closure interface in the code that can be appped on the arbitrary input object and code permits to apply Closures to contents of collection. There is Closure called BeanPropertyValueChangeClosure sets specified property to specified value. This value can be combined with commons-collections in which all the beans will have specified property to specified value in the collection.

For instance, you can set the myCar property to TRUE for entire collection as shown below:

 
 //creating the closure
 BeanPropertyValueChangeClosure closure = new BeanPropertyValueChangeClosure( "myCar", Boolean.TRUE );

 //updating the Collection
 CollectionUtils.forAllDo( myCollection, closure );
Advertisements