Thursday 30 August 2007

Get the generic type of a generic class

A simple java line allows to do that :
[java]
(Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];

Monday 4 June 2007

JXPathContext on java Objects

JxPath is a very usefull API to manipulate XML. But you can also use it to navigate an modify Java object : JXPathContext for java object
 public class Employee {
    public Address getHomeAddress(){
       ...
    }
 }
 public class Address {
    public String getStreetNumber(){
       ...
    }
 }
 
 Employee emp = new Employee();
 ...
 
 JXPathContext context = JXPathContext.newContext(emp);
 String sNumber = (String)context.getValue("homeAddress/streetNumber");

A very good way to make introspection...

Thursday 5 April 2007

Jumping in Implementation class in Eclipse and not in the interface

Implementors feature is a very good plugin to jump in Implementation class of an interface pressing Ctrl+Alt+F3. A very good feature to improve our productivity ;)

Thanks Titom for this very good tip!