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

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

本文整理了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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. private Properties appiumPropertiesFrom(EnvironmentVariables environmentVariables) {
  2. Properties appiumProperties = new Properties();
  3. List<String> appiumKeys = filter(startsWith("appium."), environmentVariables.getKeys());
  4. for (String key : appiumKeys) {
  5. String value = isAppProperty(key) ? appPathFrom(environmentVariables.getProperty(key)) : environmentVariables.getProperty(key);
  6. String simplifiedKey = key.replace("appium.", "");
  7. appiumProperties.setProperty(simplifiedKey, value);
  8. }
  9. ensureAppPathDefinedIn(appiumProperties);
  10. return appiumProperties;
  11. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Find the failing test outcomes in this set
  3. *
  4. * @return A new set of test outcomes containing only the failing tests
  5. */
  6. public TestOutcomes getFailingTests() {
  7. return TestOutcomes.of(filter(withResult(TestResult.FAILURE), outcomes))
  8. .withLabel(labelForTestsWithStatus("failing tests"))
  9. .withRootOutcomes(getRootOutcomes());
  10. }

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

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

相关文章