TypeConverter result = null ;
try {
// Case 1: Some kind of collection.
if (Iterable.class.isAssignableFrom(type.cls())) {
EvaluatedClassDeclaration type2 =
(EvaluatedClassDeclaration)getReturnType( type, "iterator") ;
if (type2 == null) {
throw Exceptions.self.iteratorNotFound(type) ;
}
EvaluatedType tcType = getReturnType( type2, "next" ) ;
if (tcType == null) {
throw Exceptions.self.nextNotFound(type) ;
}
TypeConverter tc = mom.getTypeConverter( tcType ) ;
result = new TypeConverterListBase( type, tc ) {
protected Iterator getIterator( Object obj ) {
if (obj == null) {
return emptyIterator() ;
} else {
return ((Iterable)obj).iterator() ;
}
}
} ;
} else if (Collection.class.isAssignableFrom(type.cls())) {
EvaluatedClassDeclaration type2 =
(EvaluatedClassDeclaration)getReturnType( type, "iterator") ;
EvaluatedType tcType = getReturnType( type2, "next" ) ;
TypeConverter tc = mom.getTypeConverter( tcType ) ;
result = new TypeConverterListBase( type, tc ) {