TrigerSoft/jaque

hello , how to get child class

Closed this issue · 1 comments

eg:

================
public class BaseEntity implements Serializable
protected Integer Id;
...
}

public class Foo extends BaseEntity{ ... }

public class Fluent<T>{
  private Class clz; 
  public interface Property<T, R> extends Function<T, R>, Serializable { }
  public Fluent parse(Property<T, ?> propertyRef){
       LambdaExpression<Property<T, ?>> expression = LambdaExpression.parse(propertyRef);
        List<ParameterExpression> params = expression.getParameters();
        this.clz = params.get(0).getResultType();
        System.err.println("clz= "+this.clz);
}
===================
Then Call by:

Fluent<Foo> f = new Fluent<Foo>();
f.parse(Foo::getId)

ending ==> print out : clz = BaseEntity
but, I need to print out " Foo" of class name;
help, How can i do ...
THX !

Hey @mailtous, unfortunately what you ask is impossible. JaQue relies on byte code to produce the expression tree. Since java compiler puts there BaseEntity (implementing class), JaQue returns it. You may consider passing it in the method signature, e.g.:

parse(Property<T, ?> propertyRef, Class<T> clz) { ... }