Closed GoogleCodeExporter closed 9 years ago
In class CollectionConverter line 130, Twig hits the IllegalArgumentException
IllegalArgumentException("Unsupported Collection type " + type + ". Try
declaring the
interface instead of the concrete collection type.");
Original comment by harsh.je...@gmail.com
on 26 May 2010 at 10:03
Original comment by jdpatterson
on 26 May 2010 at 10:37
In line 130 CollectionConverter, I added and fixed the problem.
Can you please add it to the main branch for 1.0.2?
else if(erased.isAssignableFrom(EnumSet.class)){
@SuppressWarnings("unchecked")
EnumSet result = EnumSet.noneOf((Class<? extends Enum>)componentType);
for(Object item : convertedItems){
result.add(Enum.valueOf((Class<? extends Enum>)componentType, item.toString()));
}
return (T) result;
}
Original comment by harsh.je...@gmail.com
on 26 May 2010 at 4:24
Nice one. Will add it to hg and it will be included in the next binary. I'll
factor out the collection creation code
so its easy to override to add new collection types.
I had purposely not implemented different types of collections here as it will
never be possible to add them all.
The recommended approach was to create a new TypeConverter and register it.
But there is enough difficult
code here to make that a pain in the ass (e.g. converting the component types)
so it makes sense to extend this
base class.
Original comment by jdpatterson
on 26 May 2010 at 4:41
Yes refactoring this CollectionConverter would help to add new collections.
I was worried about the item.toString() I use. it may cause an issue if someone
overrides the toString() method of their enum. Not sure what else to do? any
ideas?
Also please let me know as soon as you add it to hg, i'd like to check that out
and be
compatible with your branch :)
Original comment by harsh.je...@gmail.com
on 27 May 2010 at 3:06
thanks! can you close this issue after adding this code snippet to hg.
Original comment by harsh.je...@gmail.com
on 27 May 2010 at 1:07
Hi John
Can you please add this small fix to hg? I would like to also get the other
nice
updates you have and I don't want that to break my code :)
thanks!
Harsh
Original comment by harsh.je...@gmail.com
on 30 May 2010 at 3:50
Checked in now with unit test. It is now easier to add additional collection
types by overridding
createCollectionInstance(...)
Original comment by jdpatterson
on 6 Jun 2010 at 8:03
Original issue reported on code.google.com by
harsh.je...@gmail.com
on 26 May 2010 at 9:11Attachments: