co.streamx.fluent.extree.expression.MemberExpression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ex-tree Show documentation
Show all versions of ex-tree Show documentation
Build AST from the bytecode
The newest version!
package co.streamx.fluent.extree.expression;
import java.lang.reflect.Constructor;
import java.lang.reflect.Member;
import java.util.List;
import lombok.Getter;
/**
* Represents accessing a field or method.
*
*
*/
@Getter
public final class MemberExpression extends InvocableExpression {
private final Expression instance;
private final Member member;
MemberExpression(int expressionType, Expression instance, Member member, Class> resultType,
List params) {
super(expressionType, resultType, params);
this.instance = instance;
this.member = member;
}
@Override
protected T visit(ExpressionVisitor v) {
return v.visit(this);
}
@Override
public String toString() {
Member m = getMember();
String me = getInstance() != null ? getInstance().toString() : m.getDeclaringClass().getSimpleName();
return me + "." + (m instanceof Constructor> ? "" : m.getName());
}
}