I have the following Groovy domain class:
class A {
def lotOfBs = []
}
Now, from a Java class I need to iterate that array. These solutions did not work:
for ( B b : a.getLotOfBs() ){
//COMPILATION ERROR
}
for ( int i = 0 ; i < a.getLotOfBs().length ; i++ ){
//LENGTH ATTRIBUTE DOES NOT EXIST OR IT IS NOT VISIBLE
}
for ( int i = 0 ; i < a.getLotOfBs().size() ; i++ ){
//SIZE METHOD DOES NOT EXIST
}
Do you have any suggestions?
Thanks in advance
The array in groovy class is an instance of java.util.ArrayList, so casting to Collection<T> should work: