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


Java Or类代码示例

本文整理汇总了Java中com.googlecode.cqengine.query.logical.Or的典型用法代码示例。如果您正苦于以下问题:Java Or类的具体用法?Java Or怎么用?Java Or使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Or类属于com.googlecode.cqengine.query.logical包,在下文中一共展示了Or类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matchesNonSimpleAttribute

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
@Override
protected boolean matchesNonSimpleAttribute(Attribute<O, HybridTimestamp> attribute, O object, QueryOptions
        queryOptions) {
    Query<O> actualQuery = query == null ? queryFunction.apply(object) : query;
    Optional<Boolean> terminatedQuery = terminatedQuery(object, actualQuery, queryOptions);
    if (terminatedQuery.isPresent()) {
        return terminatedQuery.get();
    }
    Iterable<HybridTimestamp> values = attribute.getValues(object, queryOptions);
    List<Query<O>> conditions = StreamSupport.stream(values.spliterator(), false)
                                             .map(v -> greaterThan(timestampAttribute, v))
                                             .collect(Collectors.toList());
    Query<O> timestampQuery = conditions.size() == 1 ? conditions.get(0) : new Or<>(conditions);
    IndexedCollection<O> collection = (IndexedCollection<O>) getCollection(queryOptions);
    try (ResultSet<O> resultSet = collection.retrieve(and(
            actualQuery,
            timestampQuery))) {
        return matches(resultSet, actualQuery, object, queryOptions);
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:21,代码来源:IsLatestEntity.java

示例2: getMappers

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
private static Map<Class<? extends Query>, Mapper> getMappers(){
    HashMap<Class<? extends Query>,Mapper> map = new HashMap<>();
    
    //Simple
    map.put(Equal.class,new EqualMapper());
    map.put(GreaterThan.class,new GreaterThanMapper());
    map.put(LessThan.class,new LessThanMapper());
    map.put(Between.class,new BetweenMapper());
    map.put(Has.class,new HasMapper());
    
    //Logical
    map.put(And.class,new AndMapper());
    map.put(Or.class,new OrMapper());
    map.put(Not.class,new NotMapper());
    
    return Collections.unmodifiableMap(map);
}
 
开发者ID:cr0wbar,项目名称:Bananarama,代码行数:18,代码来源:CQE2SQL.java

示例3: getQueryClassesForAutomatedValidation

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
/**
 * Returns Query classes whose equals() and hashCode() methods can be validated by EqualsVerifier.
 */
@SuppressWarnings("unchecked")
@DataProvider
public static List<List<Class>> getQueryClassesForAutomatedValidation() {
    return Arrays.asList(
            Arrays.<Class>asList(And.class),
            Arrays.<Class>asList(Between.class),
            Arrays.<Class>asList(Equal.class),
            Arrays.<Class>asList(ExistsIn.class),
            Arrays.<Class>asList(GreaterThan.class),
            Arrays.<Class>asList(Has.class),
            Arrays.<Class>asList(LessThan.class),
            Arrays.<Class>asList(Not.class),
            Arrays.<Class>asList(Or.class),
            Arrays.<Class>asList(StringContains.class),
            Arrays.<Class>asList(StringEndsWith.class),
            Arrays.<Class>asList(StringIsContainedIn.class),
            Arrays.<Class>asList(StringMatchesRegex.class),
            Arrays.<Class>asList(StringStartsWith.class)
    );
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:24,代码来源:QueriesEqualsAndHashCodeTest.java

示例4: or

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
/**
 * Overloaded variant of {@link #or(Query, Query, Query[])} - see that method for details.
 * <p>
 * Note: This method is unnecessary as of Java 7, and is provided only for backward compatibility with Java 6 and
 * earlier, to eliminate generic array creation warnings output by the compiler in those versions.
 */
@SuppressWarnings({"JavaDoc"})
static <O extends Entity> Or<EntityHandle<O>> or(Query<EntityHandle<O>> query1, Query<EntityHandle<O>> query2, Query<EntityHandle<O>> query3) {
    @SuppressWarnings({"unchecked"})
    Collection<Query<EntityHandle<O>>> queries = Arrays.asList(query1, query2, query3);
    return new Or<>(queries);
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:13,代码来源:QueryFactory.java

示例5: or

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
/**
 * Overloaded variant of {@link #or(Query, Query, Query[])} - see that method for details.
 * <p>
 * Note: This method is unnecessary as of Java 7, and is provided only for backward compatibility with Java 6 and
 * earlier, to eliminate generic array creation warnings output by the compiler in those versions.
 */
@Deprecated
@SuppressWarnings({"JavaDoc"})
static <O extends Entity> Or<EntityHandle<O>> or(Query<EntityHandle<O>> query1, Query<EntityHandle<O>> query2, Query<EntityHandle<O>> query3) {
    @SuppressWarnings({"unchecked"})
    Collection<Query<EntityHandle<O>>> queries = Arrays.asList(query1, query2, query3);
    return new Or<>(queries);
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:14,代码来源:EntityQueryFactory.java

示例6: map

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
@Override @SuppressWarnings("unchecked")
public String map(Or<?> q) {
    StringBuilder sb = new StringBuilder();
    //Open parenthesis
    sb.append(SC);
    
    //Prepare first block from logical child queries, if any
    if(q.hasLogicalQueries())
        sb.append(q.getLogicalQueries()
                .stream()
                .map(lq -> CQE2SQL.getMapper((Class<LogicalQuery>) lq.getClass()).map((LogicalQuery) lq))
                .reduce( (a,b) -> a+OR+b).get());
    
    if(q.hasLogicalQueries() && q.hasSimpleQueries())
        sb.append(OR);//Connect the logical block and simple block of child queries
    
    //Prepare second block from simple child queries, if any
    if(q.hasSimpleQueries())
       sb.append(q.getSimpleQueries()
                .stream()
                .map(sq -> CQE2SQL.getMapper((Class<SimpleQuery<?,?>>)sq.getClass()).map((SimpleQuery<?, ?>) sq))
                .reduce( (a,b) -> a+OR+b).get());
        
    //Close parenthesis
    sb.append(TC);
    
    return sb.toString();
}
 
开发者ID:cr0wbar,项目名称:Bananarama,代码行数:29,代码来源:OrMapper.java

示例7: or

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
/**
 * Overloaded variant of {@link #or(Query, Query, Query[])} - see that method for details.
 * <p/>
 * Note: This method is unnecessary as of Java 7, and is provided only for backward compatibility with Java 6 and
 * earlier, to eliminate generic array creation warnings output by the compiler in those versions.
 */
@SuppressWarnings({"JavaDoc"})
public static <O> Or<O> or(Query<O> query1, Query<O> query2, Query<O> query3) {
    @SuppressWarnings({"unchecked"})
    Collection<Query<O>> queries = Arrays.asList(query1, query2, query3);
    return new Or<O>(queries);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:13,代码来源:QueryFactory.java

示例8: retrieveUnion

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
/**
 * Retrieves a union of the objects matching {@link SimpleQuery}s.
 * <p/>
 * <i>Definitions:
 * For a definition of <u>retrieval cost</u> see {@link ResultSet#getRetrievalCost()}.
 * For a definition of <u>merge cost</u> see {@link ResultSet#getMergeCost()}.
 * </i>
 * <p/>
 * The algorithm employed by this method is as follows.
 * <p/>
 * For each {@link SimpleQuery} supplied, retrieves a {@link ResultSet} for that {@link SimpleQuery}
 * from the index with the lowest <u>retrieval cost</u> which supports that {@link SimpleQuery}.
 * <p/>
 * The method then returns these {@link ResultSet}s in either a {@link ResultSetUnion} or a
 * {@link ResultSetUnionAll} object, depending on whether {@code logicalDuplicateElimination} was specified
 * or not. These concatenate the wrapped {@link ResultSet}s when iterated. In the case of {@link ResultSetUnion},
 * this also ensures that duplicate objects are not returned more than once, by means of logical elimination via
 * set theory rather than maintaining a record of all objects iterated.
 *
 * @param queries A collection of {@link SimpleQuery} objects to be retrieved and unioned
 * @param queryOptions Optional parameters for the query
 * supplied specifying strategy {@link DeduplicationStrategy#LOGICAL_ELIMINATION}
 * @return A {@link ResultSet} which provides objects matching the union of results for each of the
 * {@link SimpleQuery}s
 */
ResultSet<O> retrieveUnion(final Collection<SimpleQuery<O, ?>> queries, final QueryOptions queryOptions) {
    Iterable<ResultSet<O>> resultSetsToUnion = new Iterable<ResultSet<O>>() {
        @Override
        public Iterator<ResultSet<O>> iterator() {
            return new UnmodifiableIterator<ResultSet<O>>() {

                Iterator<SimpleQuery<O, ?>> queriesIterator = queries.iterator();
                @Override
                public boolean hasNext() {
                    return queriesIterator.hasNext();
                }

                @Override
                public ResultSet<O> next() {
                    return getResultSetWithLowestRetrievalCost(queriesIterator.next(), queryOptions);
                }
            };
        }
    };
    @SuppressWarnings("unchecked")
    Collection<Query<O>> queriesTyped = (Collection<Query<O>>)(Collection<? extends Query<O>>)queries;
    Query<O> query = queriesTyped.size() == 1 ? queriesTyped.iterator().next() : new Or<O>(queriesTyped);
    // Perform deduplication as necessary...
    if (DeduplicationOption.isLogicalElimination(queryOptions)) {
        boolean indexMergeStrategyEnabled = isFlagEnabled(queryOptions, PREFER_INDEX_MERGE_STRATEGY);
        return new ResultSetUnion<O>(resultSetsToUnion, query, queryOptions, indexMergeStrategyEnabled);
    }
    else {
        return new ResultSetUnionAll<O>(resultSetsToUnion, query, queryOptions);
    }
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:57,代码来源:CollectionQueryEngine.java

示例9: testOrMethodOverloading

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testOrMethodOverloading() {
    Query<Car> q1 = has(Car.CAR_ID);
    Query<Car> q2 = has(Car.MANUFACTURER);
    Query<Car> q3 = has(Car.MODEL);
    Query<Car> q4 = has(Car.FEATURES);
    Query<Car> q5 = has(Car.PRICE);
    assertEquals(or(q1, q2), new Or<Car>(asList(q1, q2)));
    assertEquals(or(q1, q2, q3), new Or<Car>(asList(q1, q2, q3)));
    assertEquals(or(q1, q2, q3, q4), new Or<Car>(asList(q1, q2, q3, q4)));
    assertEquals(or(q1, q2, q3, q4, q5), new Or<Car>(asList(q1, q2, q3, q4, q5)));
    assertEquals(or(q1, q2, q3, q4, q5), or(q1, q2, new Query[]{q3, q4, q5}));
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:15,代码来源:QueryFactoryTest.java

示例10: testNoneOr

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
@Test
public void testNoneOr() {
    IndexedCollection<Integer> indexedCollection = new ConcurrentIndexedCollection<Integer>();
    indexedCollection.addAll(asList(1, 2, 3, 4, 5));
    IndexedCollection<Integer> collection = indexedCollection;
    final Or<Integer> query = or(
            none(Integer.class),
            lessThan(selfAttribute(Integer.class), 3)
    );
    ResultSet<Integer> results = collection.retrieve(query);
    assertEquals(2, results.size());
    assertTrue(results.iterator().hasNext());
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:14,代码来源:NoneTest.java

示例11: testAllOr

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
@Test
public void testAllOr() {
    IndexedCollection<Integer> indexedCollection = new ConcurrentIndexedCollection<Integer>();
    indexedCollection.addAll(asList(1, 2, 3, 4, 5));
    IndexedCollection<Integer> collection = indexedCollection;
    final Or<Integer> query = or(
            all(Integer.class),
            lessThan(selfAttribute(Integer.class), 3)
    );
    ResultSet<Integer> results = collection.retrieve(query, queryOptions(deduplicate(LOGICAL_ELIMINATION)));
    assertEquals(5, results.size());
    assertTrue(results.iterator().hasNext());
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:14,代码来源:AllTest.java

示例12: exitOrQuery

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
@Override
public void exitOrQuery(SQLGrammarParser.OrQueryContext ctx) {
    addParsedQuery(ctx, new Or<O>(childQueries.get(ctx)));
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:5,代码来源:SQLAntlrListener.java

示例13: exitOrQuery

import com.googlecode.cqengine.query.logical.Or; //导入依赖的package包/类
@Override
public void exitOrQuery(CQNGrammarParser.OrQueryContext ctx) {
    addParsedQuery(ctx, new Or<O>(childQueries.get(ctx)));
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:5,代码来源:CQNAntlrListener.java


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