Java BeanUtils – Operating On Collections

Java BeanUtils - Operating On Collections

This topic is about of Java BeanUtils – Operating On Collections.

Description

The Commons-Collections are build upon interfaces, implementations and utilities. It contains Closure interface in the code that can be applied 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 );

In this topic we learned about Java BeanUtils – Operating On Collections. To know more, Click Here.

This Post Has One Comment

Leave a Reply