目录

Operating On Collections

描述 (Description)

Commons-Collections基于接口,实现和实用程序构建。 它包含代码中的Closure接口,可以应用于任意输入对象,代码允许将Closures应用于集合的内容。 有一个名为BeanPropertyValueChangeClosure Closure将指定的属性设置为指定的值。 此值可以与commons-collections结合使用,其中所有bean都将指定的属性指定给集合中的指定值。

例如,您可以为整个集合设置myCar属性为TRUE,如下所示:

 
 //creating the closure
 BeanPropertyValueChangeClosure closure = new BeanPropertyValueChangeClosure( "myCar", Boolean.TRUE );
 //updating the Collection
 CollectionUtils.forAllDo( myCollection, closure );
↑回到顶部↑
WIKI教程 @2018