Monday, November 30, 2015

Is there any GWT equivalent to Class.getDeclaredField?

Basically, I want to cut down on a bunch of boilerplate code (needing to check if a list of boolean fields are true/false across a collection of objects). In normal Java, I can use Class.getDeclaredField and Field.getBoolean to do that, something like:


public static boolean allTrue(Class<? extends Object> cls, List<? extends Object> things, String fieldName) {
 
try {
 
Field field = cls.getDeclaredField(fieldName);
 
boolean val = true;
 
for (Object o : things) {
   val
= val && field.getBoolean(o);
 
}

 
return val;
 
} catch (Exception e) {
 
return false;
 
}
}


I don't see any way to accomplish the same thing in GWT code, at least not in the GWT site. Is this just not an option under GWT?

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment