Re: Accessing generic type information of bound parameters

2014-05-13 Thread Lance Java
 No, there is no way to access the generic type, this information is lost
during the compilation process.

That's not actually correct. Lets consider the following class:

public class MyClass {
   private ListFoo foos;

   public ListBar getBars() {
  ...
   }

   public void doStuffWithBaz() {
  ListBaz bazs = new ArrayListBaz();
  ...
   }
}

In this example, the ONLY generic that will be lost after compilation (due
to type erasure) is Baz. Both Foo and Bar ARE available at runtime.

@see
http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#getGenericReturnType()
http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Field.html#getGenericType()


Re: Accessing generic type information of bound parameters

2014-05-13 Thread Lance Java
Just having a quick poke through the code this could be fixed by adding the
following methods to the public API.

java.lang.reflect.Type PropertyConduit.getPropertyGenericType()
java.lang.reflect.Type Binding.getBindingGenericType()
java.lang.reflect.Type ComponentResources.getBoundGenericType(String
parameterName)

I'm guessing that only PropBinding would return a type from
getBindingGenericType(). All other bindings would return null.


Re: Accessing generic type information of bound parameters

2014-05-13 Thread Jochen Kemnade

Thanks Lance, you're correct of course.
Michael, as this is still relevant to you, could you please update the 
Affects Version/s: field of your JIRA issue (TAP5-1213) accordingly?



Am 13.05.2014 11:38, schrieb Lance Java:

No, there is no way to access the generic type, this information is lost

during the compilation process.

That's not actually correct. Lets consider the following class:

public class MyClass {
private ListFoo foos;

public ListBar getBars() {
   ...
}

public void doStuffWithBaz() {
   ListBaz bazs = new ArrayListBaz();
   ...
}
}

In this example, the ONLY generic that will be lost after compilation (due
to type erasure) is Baz. Both Foo and Bar ARE available at runtime.

@see
http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#getGenericReturnType()
http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Field.html#getGenericType()




-
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org



Re: Accessing generic type information of bound parameters

2014-05-13 Thread Jochen Kemnade

Hi Michel,

Am 12.05.2014 10:58, schrieb Michael Wyraz:

I can access the type of a bound parameter using
ComponentResources.getBoundType(parameterName). But for ListString it
returns (of course) List.class. Is there a way to access the generic
parameters of the bound type somehow?


No, there is no way to access the generic type, this information is lost 
during the compilation process.



I need this for correct (automatic) type coercion in some special cases.


You could create custom sub-classes for that purpose, e.g. StringList 
extends ArrayListString.
If you have any more questions or suggestions, please take the 
discussion to the users mailing list.


Jochen

-
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org



Re: Accessing generic type information of bound parameters

2014-05-13 Thread Michael Wyraz
I have added a comment there concerning the behaviour for literal 
bindings. But I dont have permission to change the affected version.

Thanks Lance, you're correct of course.
Michael, as this is still relevant to you, could you please update the 
Affects Version/s: field of your JIRA issue (TAP5-1213) accordingly?



Am 13.05.2014 11:38, schrieb Lance Java:
No, there is no way to access the generic type, this information is 
lost

during the compilation process.

That's not actually correct. Lets consider the following class:

public class MyClass {
private ListFoo foos;

public ListBar getBars() {
   ...
}

public void doStuffWithBaz() {
   ListBaz bazs = new ArrayListBaz();
   ...
}
}

In this example, the ONLY generic that will be lost after compilation 
(due

to type erasure) is Baz. Both Foo and Bar ARE available at runtime.

@see
http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#getGenericReturnType() 

http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Field.html#getGenericType() 






-
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org




--

Mit freundlichen Grüßen / Kind regards

Michael Wyraz

evermind GmbH
Schorlemmerstraße 1
04155 Leipzig

Tel.:   +49 (0)341-25 39 66 - 0
Fax:+49 (0)341-25 39 66 - 1
Funk:   +49 (0)177-73 00 00 3
E-Mail: michael.wy...@evermind.de

HRB: 21586
Amtsgericht Leipzig

Geschäftsführer:
Christoph Klemm


-
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org



Accessing generic type information of bound parameters

2014-05-12 Thread Michael Wyraz

Hi,

I can access the type of a bound parameter using 
ComponentResources.getBoundType(parameterName). But for ListString it 
returns (of course) List.class. Is there a way to access the generic 
parameters of the bound type somehow? I need this for correct 
(automatic) type coercion in some special cases.


Kind regards,
Michael.


-
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org