当前位置: 首页>>代码示例>>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;未经允许,请勿转载。