I just want to know your opinion on how to change the entire output function of Collections to type Iterable.
It seems to me that this is the most common code in Java these days, and everyone always returns List / Set / Map in 99% of cases, but should not be a standard return of something like
public final Iterable<String> myMethod() {
return new Iterable<String>() {
@Override
public Iterator<String> iterator() {return myVar.getColl();}
};
}
Is it really bad? You know all the DAO classes, and this stuff will look like
Iterable<String> getName(){}
Iterable<Integer> getNums(){}
Iterable<String> getStuff(){}
instead
List<String> getName(){}
List<Integer> getNums(){}
Set<String> getStuff(){}
In the end, 99% of the time you'll use it in a for ... loop
What do you think?
source
share