All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.streamx.fluent.extree.expression.MemberExpression Maven / Gradle / Ivy

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());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy