PathExpression.java 文件源码

java
阅读 37 收藏 0 点赞 0 评论 0

项目:8R-Reflections 作者:
/**
 * Returns the member that the given node index represents on the given class.
 *
 * @param index the node index (inclusive)
 * @param c the class that have this node
 * @param args the arguments that will be used to access this node.
 * @return the member
 * @see #getMemberOf(int)
 * @see #getMemberOf(int, Map)
 * @see #getMemberOf(int, Class)
 * @see #getLastMember(Class, Map)
 * @see #needArguments()
 * @throws IndexOutOfBoundsException if the index is invalid
 * @throws IllegalArgumentException if the static path expression not support the given root obj
 */
public Member getMemberOf(int index, Class<?> c, Map<String, Object> args) {
    checkIfSupport(c, true);
    checkRange("Index", index, false);
    Member member = null;
    int i = 0;
    for (ExpressionNode node : NODES) {
        member = node.getMember(c, args);
        if (i == index) {
            return member;
        }
        if (i < LAST_INDEX) {
            c = getMemberType(member);
            while (c.isArray()) {
                c = c.getComponentType();
            }
        }
        i++;
    }
    return member;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号