
- Java BeanUtils Tutorial
- Java BeanUtils - Home
- Java BeanUtils - Overview
- Standard JavaBeans
- Background
- Basic Property Access
- Nested Property Access
- Customizing Introspection
- Suppressing Properties
- Dynamic Beans (DynaBeans)
- Background
- Basic DynaBeans
- ResultSetDynaClass
- RowSetDynaClass
- WrapDynaBean
- Lazy DynaBeans
- Data Type Conversions
- Background
- BeanUtils and ConvertUtils
- Create Custom Converters
- Locale Aware Conversions
- Utility Objects & Classes
- Utility Objects & Classes
- Collections
- Comparing Beans
- Operating On Collections
- Querying Or Filtering Collections
- Transforming Collections
- Java BeanUtils Useful Resources
- Java BeanUtils - Quick Guide
- Java BeanUtils - Resources
- Java BeanUtils - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java BeanUtils - Transforming Collections
Description
The conversion from input object to output object is supported in commons-collections with the help of Transformer interface. The Transformers can be applied to get the output collection from input collection with the help of codes available in Commons-collections. BeanToPropertyTransformer is an example of Transformer that will convert a bean to its property value. This feature is able to extract a particular property from the input object and present it as output object.
If you try to find out a particular car model from many car users in a collection. The syntax is shown below:
// creating transformer BeanToPropertyValueTransformer transformer = new BeanToPropertyValueTransformer( "person.company.carmodel" ); // transforming Collection Collection carModel = CollectionUtils.collect( peopleCollection, transformer );
Advertisements