ch.lambdaj.Lambda.filter()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(321)

本文整理了Java中ch.lambdaj.Lambda.filter()方法的一些代码示例,展示了Lambda.filter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lambda.filter()方法的具体详情如下:
包路径:ch.lambdaj.Lambda
类名称:Lambda
方法名:filter

Lambda.filter介绍

[英]Filters all the objects in the given iterable that match the given hamcrest Matcher
[中]过滤给定iterable中与给定hamcrest匹配器匹配的所有对象

代码示例

代码示例来源:origin: io.cloudslang/score-orchestrator-impl

private <T extends Serializable> void dispatch(List<? extends Serializable> messages, Class<T> messageClass, Handler<T> handler){
  @SuppressWarnings("unchecked")
  List<T> filteredMessages = (List<T>) filter(Matchers.instanceOf(messageClass), messages);
  if (!messages.isEmpty()){
    handler.handle(filteredMessages);
  }
}

代码示例来源:origin: io.openscore.lang/score-lang-api

@Override
public CompilationArtifact compile(SlangSource source, Set<SlangSource> dependencies) {
  Validate.notNull(source, "Source can not be null");
  Set<SlangSource> dependencySources = new HashSet<>(filter(notNullValue(), dependencies));
  try {
    return compiler.compile(source, dependencySources);
  } catch (Exception e) {
    logger.error("Failed compilation for source : " + source.getName() + " ,Exception is : " + e.getMessage());
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: net.flexmojos.oss/flexmojos-maven-plugin

protected Set<Artifact> getDependencies( Matcher<? extends Artifact>... matchers )
{
  Set<Artifact> dependencies = getDependencies();
  return new LinkedHashSet<Artifact>( filter( allOf( matchers ), dependencies ) );
}

代码示例来源:origin: net.thucydides/thucydides-core

public static <T> List<T> filterElements(final List<T> elements, final BeanMatcher... matchers) {
  List<T> filteredItems = ImmutableList.copyOf(elements);
  for(BeanFieldMatcher matcher : propertyMatchersIn(matchers)) {
    filteredItems = filter(matcher.getMatcher(), filteredItems);
  }
  return filteredItems;
}

代码示例来源:origin: net.serenity-bdd/core

public static <T> List<T> filterElements(final List<T> elements, final BeanMatcher... matchers) {
  List<T> filteredItems = ImmutableList.copyOf(elements);
  for(BeanFieldMatcher matcher : propertyMatchersIn(matchers)) {
    filteredItems = filter(matcher.getMatcher(), filteredItems);
  }
  return filteredItems;
}

代码示例来源:origin: org.motechproject/motech-mrs-couchdb

public void addDependantObservation(MRSObservation mrsObservation) {
  List<? extends MRSObservation> existingObservationList = Lambda.filter(having(on(CouchObservation.class).getConceptName(), is(equalTo(mrsObservation.getConceptName()))), dependantObservations);
  if (!existingObservationList.isEmpty()) {
    dependantObservations.remove(existingObservationList.get(0));
  }
  dependantObservations.add(convertObservationToCouchObservation(mrsObservation));
}

代码示例来源:origin: net.thucydides/thucydides-core

private List<TestOutcome> outcomesForRelease(List<? extends TestOutcome> outcomes,
                         String releaseName) {
    releaseManager.enrichOutcomesWithReleaseTags(outcomes);
    return (List<TestOutcome>) filter(having(on(TestOutcome.class).getVersions(), hasItem(releaseName)), outcomes);
  }
}

代码示例来源:origin: org.motechproject/motech-alerts-api

@Override
  public List<Alert> filter(List<Alert> alerts, AlertCriteria alertCriteria) {
    return Lambda.filter(having(on(Alert.class).getAlertType(), equalTo(alertCriteria.alertType())), alerts);
  }
},

代码示例来源:origin: org.motechproject/motech-alerts-api

@Override
  public List<Alert> filter(List<Alert> alerts, AlertCriteria alertCriteria) {
    return Lambda.filter(having(on(Alert.class).getStatus(), equalTo(alertCriteria.alertStatus())), alerts);
  }
},

代码示例来源:origin: net.thucydides/thucydides-core

private int countDataRowsWithResult(TestResult expectedResult) {
  List<DataTableRow> matchingRows
      = filter(having(on(DataTableRow.class).getResult(), is(expectedResult)), getDataTable().getRows());
  return matchingRows.size();
}

代码示例来源:origin: net.serenity-bdd/core

private Properties appiumPropertiesFrom(EnvironmentVariables environmentVariables) {
  Properties appiumProperties = new Properties();
  List<String> appiumKeys = filter(startsWith("appium."), environmentVariables.getKeys());
  for (String key : appiumKeys) {
    String value = isAppProperty(key) ? appPathFrom(environmentVariables.getProperty(key)) : environmentVariables.getProperty(key);
    String simplifiedKey = key.replace("appium.", "");
    appiumProperties.setProperty(simplifiedKey, value);
  }
  ensureAppPathDefinedIn(appiumProperties);
  return appiumProperties;
}

代码示例来源:origin: net.serenity-bdd/core

private void addCustomPropertiesTo(Map<String, String> buildProperties) {
  List<String> sysInfoKeys = filter(startsWith("sysinfo."), environmentVariables.getKeys());
  for(String key : sysInfoKeys) {
    String simplifiedKey = key.replace("sysinfo.", "");
    String expression = environmentVariables.getProperty(key);
    String value = (isGroovyExpression(expression)) ? evaluateGroovyExpression(key, expression) : expression;
    buildProperties.put(humanizedFormOf(simplifiedKey), value);
  }
}

代码示例来源:origin: net.serenity-bdd/core

/**
 * Find the test outcomes with a given tag type
 *
 * @param tagType the tag type we are filtering on
 * @return A new set of test outcomes for this tag type
 */
public TestOutcomes withTagType(String tagType) {
  return TestOutcomes.of(filter(havingTagType(tagType), outcomes)).withLabel(tagType).withRootOutcomes(this.getRootOutcomes());
}

代码示例来源:origin: net.thucydides/thucydides-core

/**
 * Find the test outcomes with a given tag type
 *
 * @param tagType the tag type we are filtering on
 * @return A new set of test outcomes for this tag type
 */
public TestOutcomes withTagType(String tagType) {
  return TestOutcomes.of(filter(havingTagType(tagType), outcomes)).withLabel(tagType).withRootOutcomes(this.getRootOutcomes());
}

代码示例来源:origin: net.thucydides/thucydides-core

/**
 * Find the test outcomes with a given tag name
 *
 * @param tagName the name of the tag type we are filtering on
 * @return A new set of test outcomes for this tag name
 */
public TestOutcomes withTag(String tagName) {
  return TestOutcomes.of(filter(havingTagName(tagName), outcomes)).withLabel(tagName).withRootOutcomes(getRootOutcomes());
}

代码示例来源:origin: net.serenity-bdd/core

/**
 * Find the test outcomes with a given tag name
 *
 * @param tagName the name of the tag type we are filtering on
 * @return A new set of test outcomes for this tag name
 */
public TestOutcomes withTag(String tagName) {
  return TestOutcomes.of(filter(havingTagName(tagName), outcomes)).withLabel(tagName).withRootOutcomes(getRootOutcomes());
}

代码示例来源:origin: net.thucydides/thucydides-core

public TestOutcomes getErrorTests() {
  return TestOutcomes.of(filter(withResult(TestResult.ERROR), outcomes))
      .withLabel(labelForTestsWithStatus("failing tests"))
      .withRootOutcomes(getRootOutcomes());
}

代码示例来源:origin: net.serenity-bdd/core

public TestOutcomes getErrorTests() {
  return TestOutcomes.of(filter(withResult(TestResult.ERROR), outcomes))
      .withLabel(labelForTestsWithStatus("failing tests"))
      .withRootOutcomes(getRootOutcomes());
}

代码示例来源:origin: net.serenity-bdd/core

/**
 * Find the failing test outcomes in this set
 *
 * @return A new set of test outcomes containing only the failing tests
 */
public TestOutcomes getFailingTests() {
  return TestOutcomes.of(filter(withResult(TestResult.FAILURE), outcomes))
      .withLabel(labelForTestsWithStatus("failing tests"))
      .withRootOutcomes(getRootOutcomes());
}

代码示例来源:origin: net.thucydides/thucydides-core

public TestOutcomes havingResult(TestResult result) {
  return TestOutcomes.of(filter(withResult(result), outcomes))
      .withLabel(labelForTestsWithStatus(result.name()))
      .withRootOutcomes(getRootOutcomes());
}

相关文章