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


Java Iterables.removeIf方法代碼示例

本文整理匯總了Java中com.google.common.collect.Iterables.removeIf方法的典型用法代碼示例。如果您正苦於以下問題:Java Iterables.removeIf方法的具體用法?Java Iterables.removeIf怎麽用?Java Iterables.removeIf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.Iterables的用法示例。


在下文中一共展示了Iterables.removeIf方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: removeUnreadFields

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
@Override
public Iterable<? extends Field> removeUnreadFields() {
    final List<Field> removedFields = Lists.newArrayList();
    Iterables.removeIf(fields, new Predicate<Field>() {
        @Override
        public boolean apply(Field field) {
            if (!field.isRead()) {
                removedFields.add(field);
                return true;
            } else if (field.hasSchema()) {
                Iterables.addAll(removedFields, field.getAssignedSchema().removeUnreadFields());
            }

            return false;
        }
    });
    return removedFields;
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:19,代碼來源:ListSchema.java

示例2: removeUnreadFields

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
@Override
public Iterable<? extends Field> removeUnreadFields() {
    final List<Field> removedFields = Lists.newArrayList();
    Iterables.removeIf(fields.values(), new Predicate<Field>() {
        @Override
        public boolean apply(Field field) {
            if (!field.isRead()) {
                removedFields.add(field);
                return true;
            } else if (field.hasSchema()) {
                Iterables.addAll(removedFields, field.getAssignedSchema().removeUnreadFields());
            }

            return false;
        }
    });
    return removedFields;
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:19,代碼來源:ObjectSchema.java

示例3: expectMatching

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
@SuppressWarnings("checkstyle:IllegalCatch")
public static <T> List<T> expectMatching(final ActorRef actor, final Class<T> clazz, final int count,
        final Predicate<T> matcher) {
    int timeout = 5000;
    Exception lastEx = null;
    List<T> messages = Collections.emptyList();
    for (int i = 0; i < timeout / 50; i++) {
        try {
            messages = getAllMatching(actor, clazz);
            Iterables.removeIf(messages, Predicates.not(matcher));
            if (messages.size() >= count) {
                return messages;
            }

            lastEx = null;
        } catch (Exception e)  {
            lastEx = e;
        }

        Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
    }

    throw new AssertionError(String.format("Expected %d messages of type %s. Actual received was %d: %s", count,
            clazz, messages.size(), messages), lastEx);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:26,代碼來源:MessageCollectorActor.java

示例4: testReplay

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
@Test
public void testReplay() throws Exception {
    final Consumer<Response<?, ?>> callback = mock(Consumer.class);
    final Request<?, ?> request1 = createRequest(replyToProbe.ref());
    final Request<?, ?> request2 = createRequest(replyToProbe.ref());
    connection.sendRequest(request1, callback);
    connection.sendRequest(request2, callback);
    final Iterable<ConnectionEntry> entries = connection.startReplay();
    Assert.assertThat(entries, hasItems(entryWithRequest(request1), entryWithRequest(request2)));
    Assert.assertEquals(2, Iterables.size(entries));
    Iterables.removeIf(entries, e -> true);
    final ReconnectForwarder forwarder = mock(ReconnectForwarder.class);
    connection.finishReplay(forwarder);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:15,代碼來源:AbstractClientConnectionTest.java

示例5: removeBlankLinesIn

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
private void removeBlankLinesIn(Iterable<String> services) {
  Iterables.removeIf(services, Predicates.equalTo(""));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:Output.java

示例6: save

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
/**
 * Save materialization using random backoff with retries.
 * <p>
 * Note that this method is forgiving in that it just reports to the failure and quits without
 * notifying the caller. This is by design as we have no mechanism to prevent into fail-retry-fail loops.
 *
 * @param materialization materialization to save
 */
protected void save(final Materialization materialization) {
  final String jobIdStr = materialization.getJob().getJobId();
  if (jobIdStr == null) {
    logger.warn("Accelerator state updated before getting jobId for path {} -> {}. Ignoring", layout.getId().getId(),
        materialization.getId().getId());
    return;
  }

  final JobId jobId = new JobId(jobIdStr);
  int tries = 0;

  do {
    final Optional<MaterializedLayout> currentLayout = context.materializationStore.get(materialization.getLayoutId());
    if (!currentLayout.isPresent()) {
      logger.info("unable to find layout {}. cancelling materialization.", materialization.getLayoutId().getId());
      cancelJob(jobId);
    }

    final List<Materialization> materializations = Lists.newArrayList(AccelerationUtils.selfOrEmpty(currentLayout.get().getMaterializationList()));

    // delete if the same materialization exists
    Iterables.removeIf(materializations, new Predicate<Materialization>() {
      @Override
      public boolean apply(@Nullable final Materialization input) {
        return materialization.getId().equals(input.getId());
      }
    });

    // eventually we will have to sort materializations chronologically as prepending here does not guarantee ordering
    materializations.add(materialization);
    currentLayout.get().setMaterializationList(materializations);

    try {
      context.materializationStore.save(currentLayout.get());
      return;
    } catch (final ConcurrentModificationException ex) {
      randomBackoff(MAX_BACKOFF);
    }
  } while (tries++ < MAX_TRIES);

  // Failed to update after MAX_TRIES
  logger.error("Failed to save materialization with params: {}",
      MoreObjects.toStringHelper(this).add("layoutId", materialization.getLayoutId().getId()));
  cancelJob(jobId);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:54,代碼來源:MaterializationTask.java


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