当前位置: 首页>>代码示例>>Java>>正文


Java Path.matchingDescendant方法代码示例

本文整理汇总了Java中com.redhat.lightblue.util.Path.matchingDescendant方法的典型用法代码示例。如果您正苦于以下问题:Java Path.matchingDescendant方法的具体用法?Java Path.matchingDescendant怎么用?Java Path.matchingDescendant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.redhat.lightblue.util.Path的用法示例。


在下文中一共展示了Path.matchingDescendant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRequiredFields

import com.redhat.lightblue.util.Path; //导入方法依赖的package包/类
/**
 * Returns all the fields required to evaluate the given projection, query,
 * and sort
 *
 * @param md Entity metadata
 * @param p Projection
 * @param q Query
 * @param s Sort
 *
 * All arguments are optional. The returned set contains the fields required
 * to evaluate all the non-null expressions
 */
public static Set<Path> getRequiredFields(EntityMetadata md,
                                          Projection p,
                                          QueryExpression q,
                                          Sort s) {
    Set<Path> fields = new HashSet<>();
    FieldCursor cursor = md.getFieldCursor();
    // skipPrefix will be set to the root of a subtree that needs to be skipped.
    // If it is non-null, all fields with a prefix 'skipPrefix' will be skipped.
    Path skipPrefix = null;
    if (cursor.next()) {
        boolean done = false;
        do {
            Path field = cursor.getCurrentPath();
            if (skipPrefix != null) {
                if (!field.matchingDescendant(skipPrefix)) {
                    skipPrefix = null;
                }
            }
            if (skipPrefix == null) {
                FieldTreeNode node = cursor.getCurrentNode();
                LOGGER.debug("Checking if {} is included ({})", field, node);
                if (node instanceof ResolvedReferenceField
                        || node instanceof ReferenceField) {
                    skipPrefix = field;
                } else {
                    if ((node instanceof ObjectField)
                            || (node instanceof ArrayField && ((ArrayField) node).getElement() instanceof ObjectArrayElement)
                            || (node instanceof ArrayElement)) {
                        // include its member fields
                    } else if ((p != null && p.isFieldRequiredToEvaluateProjection(field))
                            || (q != null && q.isRequired(field))
                            || (s != null && s.isRequired(field))) {
                        LOGGER.debug("{}: required", field);
                        fields.add(field);
                    } else {
                        LOGGER.debug("{}: not required", field);
                    }
                    done = !cursor.next();
                }
            } else {
                done = !cursor.next();
            }
        } while (!done);
    }
    return fields;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:59,代码来源:ExpressionTranslator.java


注:本文中的com.redhat.lightblue.util.Path.matchingDescendant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。