本文整理匯總了Java中com.google.cloud.datastore.StructuredQuery.CompositeFilter類的典型用法代碼示例。如果您正苦於以下問題:Java CompositeFilter類的具體用法?Java CompositeFilter怎麽用?Java CompositeFilter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CompositeFilter類屬於com.google.cloud.datastore.StructuredQuery包,在下文中一共展示了CompositeFilter類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: backfillQueryBuilder
import com.google.cloud.datastore.StructuredQuery.CompositeFilter; //導入依賴的package包/類
private EntityQuery.Builder backfillQueryBuilder(boolean showAll, Filter... filters) {
final EntityQuery.Builder queryBuilder = Query.newEntityQueryBuilder().setKind(KIND_BACKFILL);
final List<Filter> andedFilters = Lists.newArrayList(filters);
if (!showAll) {
andedFilters.add(PropertyFilter.eq(PROPERTY_ALL_TRIGGERED, false));
andedFilters.add(PropertyFilter.eq(PROPERTY_HALTED, false));
}
if (!andedFilters.isEmpty()) {
final Filter head = andedFilters.get(0);
final Filter[] tail = andedFilters.stream().skip(1).toArray(Filter[]::new);
queryBuilder.setFilter(CompositeFilter.and(head, tail));
}
return queryBuilder;
}
示例2: testNamespaceRunQuery
import com.google.cloud.datastore.StructuredQuery.CompositeFilter; //導入依賴的package包/類
@Test
public void testNamespaceRunQuery() {
setUpQueryTests();
// [START namespace_run_query]
KeyFactory keyFactory = datastore.newKeyFactory().setKind("__namespace__");
Key startNamespace = keyFactory.newKey("g");
Key endNamespace = keyFactory.newKey("h");
Query<Key> query = Query.newKeyQueryBuilder()
.setKind("__namespace__")
.setFilter(CompositeFilter.and(
PropertyFilter.gt("__key__", startNamespace),
PropertyFilter.lt("__key__", endNamespace)))
.build();
List<String> namespaces = new ArrayList<>();
QueryResults<Key> results = datastore.run(query);
while (results.hasNext()) {
namespaces.add(results.next().getName());
}
// [END namespace_run_query]
assertEquals(ImmutableList.of("ghijklmnop"), namespaces);
}
示例3: testBasicQuery
import com.google.cloud.datastore.StructuredQuery.CompositeFilter; //導入依賴的package包/類
@Test
public void testBasicQuery() {
setUpQueryTests();
// [START basic_query]
Query<Entity> query = Query.newEntityQueryBuilder()
.setKind("Task")
.setFilter(CompositeFilter.and(
PropertyFilter.eq("done", false), PropertyFilter.ge("priority", 4)))
.setOrderBy(OrderBy.desc("priority"))
.build();
// [END basic_query]
assertValidQuery(query);
}
示例4: testCompositeFilter
import com.google.cloud.datastore.StructuredQuery.CompositeFilter; //導入依賴的package包/類
@Test
public void testCompositeFilter() {
setUpQueryTests();
// [START composite_filter]
Query<Entity> query = Query.newEntityQueryBuilder()
.setKind("Task")
.setFilter(
CompositeFilter.and(PropertyFilter.eq("done", false), PropertyFilter.eq("priority", 4)))
.build();
// [END composite_filter]
assertValidQuery(query);
}
示例5: testArrayValueInequalityRange
import com.google.cloud.datastore.StructuredQuery.CompositeFilter; //導入依賴的package包/類
@Test
public void testArrayValueInequalityRange() {
setUpQueryTests();
// [START array_value_inequality_range]
Query<Entity> query = Query.newEntityQueryBuilder()
.setKind("Task")
.setFilter(CompositeFilter.and(
PropertyFilter.gt("tag", "learn"), PropertyFilter.lt("tag", "math")))
.build();
// [END array_value_inequality_range]
QueryResults<Entity> results = datastore.run(query);
assertFalse(results.hasNext());
}
示例6: testArrayValueEquality
import com.google.cloud.datastore.StructuredQuery.CompositeFilter; //導入依賴的package包/類
@Test
public void testArrayValueEquality() {
setUpQueryTests();
// [START array_value_equality]
Query<Entity> query = Query.newEntityQueryBuilder()
.setKind("Task")
.setFilter(CompositeFilter.and(
PropertyFilter.eq("tag", "fun"), PropertyFilter.eq("tag", "programming")))
.build();
// [END array_value_equality]
assertValidQuery(query);
}
示例7: testInequalityRange
import com.google.cloud.datastore.StructuredQuery.CompositeFilter; //導入依賴的package包/類
@Test
public void testInequalityRange() {
setUpQueryTests();
// [START inequality_range]
Query<Entity> query = Query.newEntityQueryBuilder()
.setKind("Task")
.setFilter(CompositeFilter.and(
PropertyFilter.gt("created", startDate), PropertyFilter.lt("created", endDate)))
.build();
// [END inequality_range]
assertValidQuery(query);
}
示例8: testInequalityInvalid
import com.google.cloud.datastore.StructuredQuery.CompositeFilter; //導入依賴的package包/類
@Test
public void testInequalityInvalid() {
// [START inequality_invalid]
Query<Entity> query = Query.newEntityQueryBuilder()
.setKind("Task")
.setFilter(CompositeFilter.and(
PropertyFilter.gt("created", startDate), PropertyFilter.gt("priority", 3)))
.build();
// [END inequality_invalid]
assertInvalidQuery(query);
}
示例9: testEqualAndInequalityRange
import com.google.cloud.datastore.StructuredQuery.CompositeFilter; //導入依賴的package包/類
@Test
public void testEqualAndInequalityRange() {
setUpQueryTests();
// [START equal_and_inequality_range]
Query<Entity> query = Query.newEntityQueryBuilder()
.setKind("Task")
.setFilter(CompositeFilter.and(PropertyFilter.eq("priority", 4),
PropertyFilter.gt("created", startDate), PropertyFilter.lt("created", endDate)))
.build();
// [END equal_and_inequality_range]
assertValidQuery(query);
}