File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "ListOrderedMap" Watch "ListOrderedMap" New topic


Mark Spritzler

Joined: Feb 05, 2001
Posts: 17271

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?



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

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:

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17271

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:
subject: ListOrderedMap
It's not a secret anymore!