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


Java Predicates.and方法代码示例

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


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

示例1: findByFilters

import com.hazelcast.query.Predicates; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Collection<LogBean> findByFilters(JsonNode jsonNode) {
	Iterator<String> fieldNames = jsonNode.fieldNames();
	Predicate<String, LogBean> predicate = null;
	while(fieldNames.hasNext()) {
		String field = fieldNames.next();
		String value = jsonNode.get(field).asText();

		Predicate<String, LogBean> tmp = Predicates.equal(field, value);
		if(predicate == null) {
			predicate = tmp;
		} else {
			predicate = Predicates.and(predicate, tmp);
		}
	}
	return logRepository.findByPredicate(predicate);
}
 
开发者ID:Mockenize,项目名称:mockenize-server,代码行数:18,代码来源:LoggingService.java

示例2: getQuery

import com.hazelcast.query.Predicates; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static Predicate<DocumentKey, Document> getQuery(SchemaRepository repo, String pattern) {
	String[] parts = pattern.split(",");
	Predicate<DocumentKey, Document> result = null;
	for (String part: parts) {
		//logger.trace("getDocumentUris; translating query part: {}", part);
		Predicate<DocumentKey, Document> query = toPredicate(repo, part.trim());
		if (query != null) {
			if (result == null) {
				result = query;
			} else {
				result = Predicates.and(result, query);
			}
		} else {
		//	logger.info("getDocumentUris; cannot translate query part '{}' to Predicate, skipping", part);
		}
	}
	return result;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:20,代码来源:DocumentPredicateBuilder.java

示例3: notJavaDuke

import com.hazelcast.query.Predicates; //导入方法依赖的package包/类
@Test
public void notJavaDuke() {
	String FIRST_NAME_IS_JOHN = "John";
	String LAST_NAME_IS_WAYNE = "Wayne";
	String NINETEEN_SIXTY_NINE = "1969";

	Predicate<?, ?> predicate = Predicates.and(Predicates.equal("firstname", FIRST_NAME_IS_JOHN),
			Predicates.equal("lastname", LAST_NAME_IS_WAYNE));

	// Force operation to server's content, not remote
	Set<String> localKeySet = super.server_personMap.localKeySet(predicate);

	assertThat("Entry exists", localKeySet.size(), equalTo(1));
	String key = localKeySet.iterator().next();

	assertThat("Correct key", key, equalTo(NINETEEN_SIXTY_NINE));

	Person person = super.server_personMap.get(key);
	assertThat("Not invalidated", person, notNullValue());
	assertThat("@Id matches key", person.getId(), equalTo(key));
	assertThat("First name", person.getFirstname(), equalTo(FIRST_NAME_IS_JOHN));
	assertThat("Last name", person.getLastname(), equalTo(LAST_NAME_IS_WAYNE));
}
 
开发者ID:hazelcast,项目名称:spring-data-hazelcast,代码行数:24,代码来源:ClientServerIT.java

示例4: usingPredicates

import com.hazelcast.query.Predicates; //导入方法依赖的package包/类
@Test
public void usingPredicates() {
    bookRepository.save(Arrays.asList(Book.create("978-1785285332", "Getting Started With Hazelcast", 3848),
            Book.create("978-1782169970", "Infinispan Data Grid Platform Definitive Guide", 4947),
            Book.create("978-1783988181", "Mastering Redis", 6172)));

    Predicate<String, Book> predicate =
            Predicates.and(Predicates.equal("isbn", "978-1785285332"), Predicates.greaterEqual("price", 3000));

    KeyValueQuery<Predicate<String, Book>> query = new KeyValueQuery<>(predicate);

    Iterable<Book> books = keyValueOperations.find(query, Book.class);

    assertThat(StreamSupport.stream(books.spliterator(), false).map(Book::getTitle).collect(Collectors.toList()))
            .hasSize(1)
            .containsExactly("Getting Started With Hazelcast");
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:18,代码来源:SpringDataHazelcastTest.java

示例5: toHazelcastPredicate

import com.hazelcast.query.Predicates; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Predicate<Long, KfkaMessage> toHazelcastPredicate()
{
    final List<Predicate<?,?>> predicates = new LinkedList<>();
    
    // Message ID
    if (messageId != null)
    {
        predicates.add(Predicates.greaterEqual("id", messageId));
    }
    
    // Topic
    if (topic != null)
    {
        predicates.add(Predicates.equal("topic", topic));
    }
    
    if (! propertyMatch.isEmpty())
    {
        for (Entry<String, Comparable> e : propertyMatch.entrySet())
        {
            predicates.add(Predicates.equal(e.getKey(), e.getValue()));
        }
    }
    
    return Predicates.and(predicates.toArray(new Predicate[predicates.size()]));
}
 
开发者ID:ethlo,项目名称:kfka,代码行数:28,代码来源:KfkaPredicate.java

示例6: aggregatePath

import com.hazelcast.query.Predicates; //导入方法依赖的package包/类
@ManagedOperation(description="Calculates the number of unique values on the path specified")
@ManagedOperationParameters({
	@ManagedOperationParameter(name = "pathId", description = "The path identifier to aggregate on")})
public int aggregatePath(int pathId) {

	IMap<DataKey, Elements> elts = hzClient.getMap(CN_XDM_ELEMENT);
	Predicate<DataKey, Elements> q = Predicates.equal("pathId", pathId);
	Set<DataKey> keys = elts.keySet(q);
	if (keys.size() > 0) {
		q = Predicates.and(Predicates.equal("pathId", pathId), new GroupCountPredicate());
		elts.keySet(q);
	}
	return keys.size();
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:15,代码来源:ModelManagement.java

示例7: getTypedPathWithRegex

import com.hazelcast.query.Predicates; //导入方法依赖的package包/类
@Override
protected Set<Map.Entry<String, Path>> getTypedPathWithRegex(String regex, String root) {
	regex = regex.replaceAll("\\{", Matcher.quoteReplacement("\\{"));
	regex = regex.replaceAll("\\}", Matcher.quoteReplacement("\\}"));
	Predicate<String, Path> filter = new RegexPredicate("path", regex);
	if (root != null) {
		filter = Predicates.and(filter, Predicates.equal("root", root));
	}
	Set<Map.Entry<String, Path>> entries = pathCache.entrySet(filter);
	return entries;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:12,代码来源:ModelManagementImpl.java

示例8: getDocumentsOfType

import com.hazelcast.query.Predicates; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Set<DocumentKey> getDocumentsOfType(String root) {
  		Predicate<DocumentKey, Document> f = Predicates.and(Predicates.equal(fnRoot, root),
  				Predicates.equal(fnTxFinish, TX_NO));
	return docCache.keySet(f);
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:7,代码来源:DocumentManagementImpl.java

示例9: and

import com.hazelcast.query.Predicates; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected Predicate<?, ?> and(Part part, Predicate<?, ?> base, Iterator<Object> iterator) {
	Predicate<?, ?> criteria = this.from(part, (Iterator<Comparable<?>>) (Iterator) iterator);
	return Predicates.and(base, criteria);
}
 
开发者ID:hazelcast,项目名称:spring-data-hazelcast,代码行数:7,代码来源:HazelcastQueryCreator.java

示例10: prepareFilters

import com.hazelcast.query.Predicates; //导入方法依赖的package包/类
private <T extends HazelcastEntity> Predicate prepareFilters(Long id, Collection<String> deviceIds, Collection<Long> networkIds,
        Collection<Long> deviceTypeIds, Collection<String> names, Date timestampSt, Date timestampEnd,
        boolean returnUpdated, String status, Class<T> entityClass) {
    final List<Predicate> predicates = new ArrayList<>();
    if (id != null) {
        predicates.add(Predicates.equal(ID.getField(), id));
    }

    if (deviceIds != null && !deviceIds.isEmpty()) {
        predicates.add(Predicates.in(DEVICE_IDS.getField(), deviceIds.toArray(new String[deviceIds.size()])));
    }

    if (networkIds != null && !networkIds.isEmpty()) {
        predicates.add(Predicates.in(NETWORK_IDS.getField(), networkIds.toArray(new Long[networkIds.size()])));
    }

    if (deviceTypeIds != null && !deviceTypeIds.isEmpty()) {
        predicates.add(Predicates.in(DEVICE_TYPE_IDS.getField(), deviceTypeIds.toArray(new Long[deviceTypeIds.size()])));
    }

    String searchableField = entityClass.equals(DeviceCommand.class) ? COMMAND.getField() : NOTIFICATION.getField();
    
    if (!CollectionUtils.isEmpty(names)) {
        predicates.add(Predicates.in(searchableField, names.toArray(new String[names.size()])));
    }
    
    if (returnUpdated) {
        predicates.add(Predicates.equal(IS_UPDATED.getField(), returnUpdated));
    }

    if (timestampSt != null) {
        String searchableFieldSt = returnUpdated ? LAST_UPDATED.getField() : TIMESTAMP.getField();
        predicates.add(Predicates.greaterThan(searchableFieldSt, timestampSt.getTime()));
    }

    if (timestampEnd != null) {
        String searchableFieldEnd = returnUpdated ? LAST_UPDATED.getField() : TIMESTAMP.getField();
        predicates.add(Predicates.lessThan(searchableFieldEnd, timestampEnd.getTime()));
    }


    if (StringUtils.isNotEmpty(status)) {
        predicates.add(Predicates.equal(STATUS.getField(), status));
    }

    final Predicate[] predicatesArray = new Predicate[predicates.size()];
    for (int i = 0; i < predicates.size(); i++) {
        predicatesArray[i] = predicates.get(i);
    }

    return Predicates.and(predicatesArray);
}
 
开发者ID:devicehive,项目名称:devicehive-java-server,代码行数:53,代码来源:HazelcastHelper.java


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