當前位置: 首頁>>代碼示例>>Java>>正文


Java CompositeFilter類代碼示例

本文整理匯總了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;
}
 
開發者ID:spotify,項目名稱:styx,代碼行數:19,代碼來源:DatastoreStorage.java

示例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);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:22,代碼來源:ConceptsTest.java

示例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);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:14,代碼來源:ConceptsTest.java

示例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);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:13,代碼來源:ConceptsTest.java

示例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());
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:14,代碼來源:ConceptsTest.java

示例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);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:13,代碼來源:ConceptsTest.java

示例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);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:13,代碼來源:ConceptsTest.java

示例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);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:12,代碼來源:ConceptsTest.java

示例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);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:13,代碼來源:ConceptsTest.java


注:本文中的com.google.cloud.datastore.StructuredQuery.CompositeFilter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。