本文整理汇总了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);
}
示例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;
}
示例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));
}
示例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");
}
示例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()]));
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}