The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 |
From: Ammar Belakhel <ammar.belak...@gmail.com>
Date: Mon, 5 Oct 2009 13:18:50 -0700 (PDT)
Local: Mon, Oct 5 2009 4:18 pm
Subject: GWT Generator
Hi,
I am facing a problem with the JType class, I want to determine if the
return type of a method is an instance of the String class.
This is my solution:
JMethod method = ...;
JType returnType = method.getReturnType();
if (returnType instanceof JClassType) {
JClassType type = (JClassType) returnType;
String name = type.getName();
if (name.equals(String.class.getName())) {
// ....
}
}
Is there an efficient way to determine if the return type of method is
an instance of given class?
Thanks.
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
From: Thomas Broyer <t.bro...@gmail.com>
Date: Tue, 6 Oct 2009 09:37:42 -0700 (PDT)
Local: Tues, Oct 6 2009 12:37 pm
Subject: Re: GWT Generator
On 5 oct, 22:18, Ammar Belakhel <ammar.belak...@gmail.com> wrote:
> Hi,
> I am facing a problem with the JType class, I want to determine if the
> return type of a method is an instance of the String class.
> This is my solution:
> JMethod method = ...;
> JType returnType = method.getReturnType();
> if (returnType instanceof JClassType) {
> JClassType type = (JClassType) returnType;
> String name = type.getName();
> if (name.equals(String.class.getName())) {
> // ....
> }
> }
> Is there an efficient way to determine if the return type of method is
> an instance of given class?
Use the TypeOracle's findType or getType method and then compare the
JClassType instances for equality:
JClassType javaLangString = oracle.findType("java.lang.String");
...
if (returnType == javaLangString) { ... }
(note: you can use reference equality, because TypeOracle guarantees
JClassType for a given class are singletons)
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
From: Ammar Belakhel <ammar.belak...@gmail.com>
Date: Sat, 7 Nov 2009 05:14:38 -0800 (PST)
Local: Sat, Nov 7 2009 8:14 am
Subject: Re: GWT Generator
You must Sign in before you can post messages.
You do not have the permission required to post.
|
|
|