I have a standard Java bean, MyJavaBean. Let's say it has 50 variables, and I created 50 getters and 50 setters with an eclipse.
This bean is filled with some pipeline business logic, and now I want to go through all 50 elements. For example, to implement the string method. Naturally, I do not want to call each method getter.
Now there are some obvious but lengthy approaches:
we implement a bean so that it keeps the set of its elements up to date as soon as it goes, and then just write getter for this
manually implement an iterator by adding each item to the collection and returning that
I have two questions:
If I have a bean with 50 elements, have I already made a mistake? Is this a negative picture?
How can I make it smarter? Is there any library that will return a collection of elements based on a JavaBean using reflection or something similar?
source
share