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
(suspended)
accept rate: 66%

edited 20.02.2014 at 08:57

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦
(suspended)


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.9k202857
accept rate: 74%

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:

×33

Asked: 19.02.2014 at 13:18

Seen: 2,078 times

Last updated: 20.02.2014 at 08:57