Hello IvyTeam

Is there a simple way calling self made generic classes? Like the List.

Data:
dao Dao<item>

in Ivyscript:
calling dao.get(id) the response would be of type Item.

generic Class:
T get(int id)

It would be great if there is a solution.

Thanks for an answer and Greetings

Edit: Trying to extend a class with the Generic doesn't help any further.
In java code those objects return items as it should and in ivyscript Objects are still returned.

public class DaoItemTest extends Dao<Item> {
    public DaoItemTest() {
        super(Item.class);
    }
}

asked 19.02.2014 at 13:18

Alexis's gravatar image

Alexis
719912
accept rate: 66%

edited 20.02.2014 at 08:57

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦
1.8k5723


At the moment IvyScript can handle Generics only on its own List<?> class. On all other classes Generics are ignored. There is already a feature request for this. See issue 18147. As a workaround you can cast the result of the generic method to the right type:

item myItem = dao.get(0) as item;
link

answered 20.02.2014 at 08:56

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.2k172450
accept rate: 73%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×30

Asked: 19.02.2014 at 13:18

Seen: 850 times

Last updated: 20.02.2014 at 08:57