|
Re: Xtend java extensions with primitive type parameters [message #545552 is a reply to message #545539] |
Thu, 08 July 2010 08:48 |
|
Hello,
no this is not possible directly. but you can solve this by using the famous adapter pattern:
guess you have a class like this
package template;
public class Helper {
public static String test(int i) {
return i + ">>";
}
}
and want to pass an xpand/xtend Integer (which is a java.lang.Long actually)
to it you build an adaper class
package template;
public class Adapter {
public static String test(Long l) {
return Helper.test((int) l.longValue());
}
}
and use it from your java extension
String test(Integer i) :
JAVA template.Adapter.test(java.lang.Long);
note: the ranges of long and int differ and my Adaper impl cannot handle this. to be sure not to get unexpected behaviour you should change this.
Regards
Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03952 seconds