[JBoss JIRA] (ROASTER-45) Using generic list with className
by Nicolas Challut (JIRA)
[ https://issues.jboss.org/browse/ROASTER-45?page=com.atlassian.jira.plugin... ]
Nicolas Challut updated ROASTER-45:
-----------------------------------
Description:
If you use a generic with class name, an exception is thrown
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at java.util.Collections$UnmodifiableList.get(Collections.java:1211)
at org.jboss.forge.roaster.model.impl.FieldImpl.setType(FieldImpl.java:345)
at org.jboss.forge.roaster.model.impl.PropertyImpl.createField(PropertyImpl.java:215)
at org.jboss.forge.roaster.model.impl.AbstractJavaSourceMemberHolder.addProperty(AbstractJavaSourceMemberHolder.java:511)
at core.TestRoaster.main(TestRoaster.java:14)
was:If you use a generic with class name,
> Using generic list with className
> ---------------------------------
>
> Key: ROASTER-45
> URL: https://issues.jboss.org/browse/ROASTER-45
> Project: Roaster
> Issue Type: Bug
> Affects Versions: 2.9.0.Final
> Environment: Window 7 x64_86
> Reporter: Nicolas Challut
>
> If you use a generic with class name, an exception is thrown
> Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
> at java.util.ArrayList.rangeCheck(ArrayList.java:635)
> at java.util.ArrayList.get(ArrayList.java:411)
> at java.util.Collections$UnmodifiableList.get(Collections.java:1211)
> at org.jboss.forge.roaster.model.impl.FieldImpl.setType(FieldImpl.java:345)
> at org.jboss.forge.roaster.model.impl.PropertyImpl.createField(PropertyImpl.java:215)
> at org.jboss.forge.roaster.model.impl.AbstractJavaSourceMemberHolder.addProperty(AbstractJavaSourceMemberHolder.java:511)
> at core.TestRoaster.main(TestRoaster.java:14)
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
11 years, 5 months
[JBoss JIRA] (ROASTER-44) Support writing of nested annotation arrays
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-44?page=com.atlassian.jira.plugin... ]
George Gastaldi commented on ROASTER-44:
----------------------------------------
Same goes for {{setAnnotationValue()}}, we should have an overloaded method to receive an {{Annotation}} object
> Support writing of nested annotation arrays
> -------------------------------------------
>
> Key: ROASTER-44
> URL: https://issues.jboss.org/browse/ROASTER-44
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT
> Affects Versions: 2.9.0.Final
> Reporter: George Gastaldi
> Assignee: Matt Benson
> Fix For: 2.9.1.Final
>
>
> Roaster should allow annotation nesting, like:
> {code}
> @NamedQueries({
> @NamedQuery(name="Customer.findAll", query="select C from Customer C"),
> @NamedQuery(name="Customer.findByName", query="select C from Customer C where C.name = :name"),
> @NamedQuery(name="Customer.findById", query="select C from Customer C where C.id = :id")
> })
> @Entity
> public class Customer {...}
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
11 years, 5 months
[JBoss JIRA] (ROASTER-44) Support writing of nested annotation arrays
by Matt Benson (JIRA)
[ https://issues.jboss.org/browse/ROASTER-44?page=com.atlassian.jira.plugin... ]
Matt Benson commented on ROASTER-44:
------------------------------------
Well, that is reasonable then. :-)
> Support writing of nested annotation arrays
> -------------------------------------------
>
> Key: ROASTER-44
> URL: https://issues.jboss.org/browse/ROASTER-44
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT
> Affects Versions: 2.9.0.Final
> Reporter: George Gastaldi
> Assignee: Matt Benson
> Fix For: 2.9.1.Final
>
>
> Roaster should allow annotation nesting, like:
> {code}
> @NamedQueries({
> @NamedQuery(name="Customer.findAll", query="select C from Customer C"),
> @NamedQuery(name="Customer.findByName", query="select C from Customer C where C.name = :name"),
> @NamedQuery(name="Customer.findById", query="select C from Customer C where C.id = :id")
> })
> @Entity
> public class Customer {...}
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
11 years, 5 months
[JBoss JIRA] (ROASTER-44) Support writing of nested annotation arrays
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-44?page=com.atlassian.jira.plugin... ]
George Gastaldi commented on ROASTER-44:
----------------------------------------
Right, maybe setName(Class<?>) would make sense in this case.
I have also the situation where a JPA Entity has a {{@NamedQuery}} and I need to move it to inside a {{@NamedQueries}} annotation, that's where the {{addAnnotationValue(Annotation<O> element);}} helps
> Support writing of nested annotation arrays
> -------------------------------------------
>
> Key: ROASTER-44
> URL: https://issues.jboss.org/browse/ROASTER-44
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT
> Affects Versions: 2.9.0.Final
> Reporter: George Gastaldi
> Assignee: Matt Benson
> Fix For: 2.9.1.Final
>
>
> Roaster should allow annotation nesting, like:
> {code}
> @NamedQueries({
> @NamedQuery(name="Customer.findAll", query="select C from Customer C"),
> @NamedQuery(name="Customer.findByName", query="select C from Customer C where C.name = :name"),
> @NamedQuery(name="Customer.findById", query="select C from Customer C where C.id = :id")
> })
> @Entity
> public class Customer {...}
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
11 years, 5 months
[JBoss JIRA] (ROASTER-44) Support writing of nested annotation arrays
by Matt Benson (JIRA)
[ https://issues.jboss.org/browse/ROASTER-44?page=com.atlassian.jira.plugin... ]
Matt Benson commented on ROASTER-44:
------------------------------------
In turn, my concern is that this approach effectively short-circuits the main API, diminishing overall uniformity for no real reason AFAICT.
> Support writing of nested annotation arrays
> -------------------------------------------
>
> Key: ROASTER-44
> URL: https://issues.jboss.org/browse/ROASTER-44
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT
> Affects Versions: 2.9.0.Final
> Reporter: George Gastaldi
> Assignee: Matt Benson
> Fix For: 2.9.1.Final
>
>
> Roaster should allow annotation nesting, like:
> {code}
> @NamedQueries({
> @NamedQuery(name="Customer.findAll", query="select C from Customer C"),
> @NamedQuery(name="Customer.findByName", query="select C from Customer C where C.name = :name"),
> @NamedQuery(name="Customer.findById", query="select C from Customer C where C.id = :id")
> })
> @Entity
> public class Customer {...}
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
11 years, 5 months
[JBoss JIRA] (ROASTER-44) Support writing of nested annotation arrays
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-44?page=com.atlassian.jira.plugin... ]
George Gastaldi commented on ROASTER-44:
----------------------------------------
My only concern with addAnnotationValue(Class<?>) is to add the import. I am not 100% sure that setName() should be the overloaded option.
This is my implementation of the addAnnotationValue(Class<?>):
{code}
@Override
public AnnotationSource<O> addAnnotationValue(Class<? extends java.lang.annotation.Annotation> type)
{
if (!getOrigin().hasImport(type))
{
getOrigin().addImport(type);
}
return addAnnotationValue().setName(type.getSimpleName());
}
@Override
public AnnotationSource<O> addAnnotationValue(String name, Class<? extends java.lang.annotation.Annotation> type)
{
if (!getOrigin().hasImport(type))
{
getOrigin().addImport(type);
}
return addAnnotationValue(name).setName(type.getSimpleName());
}
{code}
> Support writing of nested annotation arrays
> -------------------------------------------
>
> Key: ROASTER-44
> URL: https://issues.jboss.org/browse/ROASTER-44
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT
> Affects Versions: 2.9.0.Final
> Reporter: George Gastaldi
> Assignee: Matt Benson
> Fix For: 2.9.1.Final
>
>
> Roaster should allow annotation nesting, like:
> {code}
> @NamedQueries({
> @NamedQuery(name="Customer.findAll", query="select C from Customer C"),
> @NamedQuery(name="Customer.findByName", query="select C from Customer C where C.name = :name"),
> @NamedQuery(name="Customer.findById", query="select C from Customer C where C.id = :id")
> })
> @Entity
> public class Customer {...}
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
11 years, 5 months
[JBoss JIRA] (ROASTER-44) Support writing of nested annotation arrays
by Matt Benson (JIRA)
[ https://issues.jboss.org/browse/ROASTER-44?page=com.atlassian.jira.plugin... ]
Matt Benson edited comment on ROASTER-44 at 11/19/14 8:33 AM:
--------------------------------------------------------------
Are you saying you are having trouble setting the type of the nested annotation? The only way, right now, would be calling {{#setName()}} with the FQ or simple classname. We should probably overload {{Annotation#setName()}} IMO. Then we can handle the import as well.
was (Author: mbenson):
Are you saying you are having trouble setting the type of the nested annotation? The only way, right now, would be calling {{#setName()}} with the FQ or simple classname. We should probably overload {{Annotation#setName()}} IMO.
> Support writing of nested annotation arrays
> -------------------------------------------
>
> Key: ROASTER-44
> URL: https://issues.jboss.org/browse/ROASTER-44
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT
> Affects Versions: 2.9.0.Final
> Reporter: George Gastaldi
> Assignee: Matt Benson
> Fix For: 2.9.1.Final
>
>
> Roaster should allow annotation nesting, like:
> {code}
> @NamedQueries({
> @NamedQuery(name="Customer.findAll", query="select C from Customer C"),
> @NamedQuery(name="Customer.findByName", query="select C from Customer C where C.name = :name"),
> @NamedQuery(name="Customer.findById", query="select C from Customer C where C.id = :id")
> })
> @Entity
> public class Customer {...}
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
11 years, 5 months