A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Feb 05, 2001
Jul 11, 2009 13:25:57
Another issue we came across that I am hoping someone has a solution for.
We are converting our
domain objects to groovy.
In one class we have a property that is of type ListOrderedMap which has
Now in our code we do a get(Integer) to return the corresponding Map.Entry
Then we call .value() on it to get the String.
The problem is that Groovy isn't returning the Map.Entry in the get, but instead an Integer object instead and tries to call getValue() on it which that method doesn't exist on an Integer object.
Anyone have this happen to them before and have a solution?
Perfect World Programming, LLC
Two Laptop Bag
How to Ask Questions the Smart Way FAQ
Joined: Apr 14, 2009
Oct 26, 2009 06:58:46
I was wondering what you were trying to do. Do you have some more code? I was playing around with:
listOrderedMap = [[1,[1:"test 1"]], [2,[2:"test 2"]]] println listOrderedMap.get(0) // Results => [1, [1:test 1]] // - or - listOrderedMap = [1:"test 1", 2:"test 2"] println listOrderedMap.get(1) // results => test 1 // - or - listOrderedMap = [[1:"test 1"], [2:"test 2"]] println listOrderedMap.get(0).get(1) println listOrderedMap.get(1).get(2) // results => test 1 // test 2
Joined: Feb 05, 2001
Oct 26, 2009 10:50:44
We were trying to have the get() method return the Map.Entry object since that was the correct type from the get method. But instead it kept returning an int.
Based on stuff that gets generated it appears that the getMetaClass for that call was trying to return the wrong type (int), which we then try to cast to Map.Entry because that is what was expected.
Our solution was to get rid of all of our ListOrderedMap into other collection classes.
I agree. Here's the link:
Generics -really very hard question
Generics and Colletions
Retrieving different keys when the values in a hashmap are same???
runtime exception during accessing elements in hashmap
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014