wood burning stoves 2.0*
The moose likes Groovy and the fly likes ListOrderedMap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "ListOrderedMap" Watch "ListOrderedMap" New topic
Author

ListOrderedMap

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Another issue we came across that I am hoping someone has a solution for.

We are converting our java domain objects to groovy.

In one class we have a property that is of type ListOrderedMap which has

List<Integer, Map.Entry><Integer, String>

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?

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Rj Salicco
Greenhorn

Joined: Apr 14, 2009
Posts: 17
I was wondering what you were trying to do. Do you have some more code? I was playing around with:



-RJ
http://www.rjsalicco.com
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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.

Mark
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ListOrderedMap
 
Similar Threads
Generics -really very hard question
runtime exception during accessing elements in hashmap
Generics and Colletions
generics
Retrieving different keys when the values in a hashmap are same???