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

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

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

Lambda.extract介绍

[英]Converts all the object in the iterable extracting the property defined by the given argument. Actually it handles also Maps, Arrays and Iterator by collecting their values. Note that this method accepts an Object in order to be used in conjunction with the Lambda#forEach(Iterable).
[中]转换iterable中的所有对象,提取给定参数定义的属性。实际上,它还通过收集映射、数组和迭代器的值来处理它们。请注意,此方法接受一个对象,以便与Lambda#forEach(Iterable)一起使用。

代码示例

代码示例来源:origin: mariofusco/lambdaj

/**
 * Counts the number of occurrencies of the argument's value in the objects of the given iterable
 * Actually it handles also Maps, Arrays and Iterator by collecting their values.
 * Note that this method accepts an Object in order to be used in conjunction with the {@link Lambda#forEach(Iterable)}.
 * @param iterable The iterable of objects' arguments to be counted
 * @param argument An argument defined using the {@link Lambda#on(Class)} method
 * @return A map having as values the number of occurrencies of the corresponding object's argument in the given iterable
 */
public static <A> Map<A, Integer> count(Object iterable, A argument) {
  return count(extract(iterable, argument));
}

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

private List<Object[]> extractStudyNamesWithIndex(List<FormGroup> allFormGroups) {
  List<String> studyNames = extract(allFormGroups, on(FormGroup.class).getName());
  List<Object[]> studyNamesWithIndex = new ArrayList<Object[]>();
  for (int i = 0; i < studyNames.size(); i++) {
    studyNamesWithIndex.add(new Object[]{i, studyNames.get(i)});
  }
  return studyNamesWithIndex;
}

代码示例来源:origin: lordofthejars/nosql-unit

private static List<byte[]> extractSortValues(JSONArray expectedValuesArray) {
  Set<SortElement> elementsOrderedByScore = new TreeSet<RedisAssertion.SortElement>();
  for (Object expectedObject : expectedValuesArray) {
    JSONObject expectedValue = (JSONObject) expectedObject;
    elementsOrderedByScore.add(new SortElement((java.lang.Number) expectedValue.get(SCORE_TOKEN),
        toByteArray(expectedValue.get(VALUE_TOKEN))));
  }
  return extract(elementsOrderedByScore, on(SortElement.class).getValue());
}

代码示例来源:origin: com.lordofthejars/nosqlunit-redis

private static List<byte[]> extractSortValues(JSONArray expectedValuesArray) {
  Set<SortElement> elementsOrderedByScore = new TreeSet<RedisAssertion.SortElement>();
  for (Object expectedObject : expectedValuesArray) {
    JSONObject expectedValue = (JSONObject) expectedObject;
    elementsOrderedByScore.add(new SortElement((java.lang.Number) expectedValue.get(SCORE_TOKEN),
        toByteArray(expectedValue.get(VALUE_TOKEN))));
  }
  return extract(elementsOrderedByScore, on(SortElement.class).getValue());
}

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

/**
 * @return The total number of nested steps in these test outcomes.
 */
public int getStepCount() {
  return sum(extract(outcomes, on(TestOutcome.class).getNestedStepCount())).intValue();
}

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

/**
 * @return The total number of nested steps in these test outcomes.
 */
public int getStepCount() {
  return sum(extract(outcomes, on(TestOutcome.class).getNestedStepCount())).intValue();
}

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

@Override
public boolean matchesSafely(TestOutcome testOutcome) {
  List<TestStep> allSteps = testOutcome.getFlattenedTestSteps();
  List<TestResult> allTestResults = extract(allSteps, on(TestStep.class).getResult());
  return allTestResults.equals(expectedTestResults);
}

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

@Override
public boolean matchesSafely(TestOutcome testOutcome) {
  List<TestStep> allSteps = testOutcome.getFlattenedTestSteps();
  List<TestResult> allTestResults = extract(allSteps, on(TestStep.class).getResult());
  return allTestResults.equals(expectedTestResults);
}

代码示例来源:origin: CloudSlang/score

@Override
  public void tryOnce() {
    String wrv = recoveryManager.getWRV();
    if (logger.isDebugEnabled()) logger.debug("Dispatch start with bulk number: " + bulkNumber);
    dispatcherService.dispatch(optimizedBulk, bulkNumber, wrv, workerUuid);
    if (executionsActivityListener != null) {
      executionsActivityListener.onHalt(extract(optimizedBulk, on(ExecutionMessage.class).getExecStateId()));
    }
    if (logger.isDebugEnabled()) logger.debug("Dispatch end with bulk number: " + bulkNumber);
  }
});

代码示例来源:origin: org.motechproject/quartz-couchdb-store-bundle

@View(name = "by_triggerGroupName", map = "function(doc) { if (doc.type === 'CouchDbTrigger') emit(doc.group, doc._id); }")
public List<String> getTriggerGroupNames() {
  return new ArrayList<String>(new HashSet<String>(extract(db.queryView(createQuery("by_triggerGroupName").includeDocs(true), type), on(CouchDbTrigger.class).getGroup())));
}

代码示例来源:origin: org.motechproject/quartz-couchdb-store-bundle

@View(name = "by_jobGroupName", map = "function(doc) { if (doc.type === 'CouchDbJobDetail') emit(doc.group, doc._id); }")
public List<String> getJobGroupNames() {
  return new ArrayList<String>(new HashSet<String>(extract(db.queryView(createQuery("by_jobGroupName").includeDocs(true), type), on(CouchDbJobDetail.class).getGroup())));
}

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

private String[] withRowDataFrom(TestOutcome outcome) {
  List<? extends Serializable> defaultValues = ImmutableList.of(outcome.getStoryTitle(),
                                 outcome.getTitle(),
                                 outcome.getResult(),
                                 outcome.getStartTime(),
                                 passRateFor(outcome),
                                 outcome.getDurationInSeconds());
  List<String> cellValues = extract(defaultValues, on(Object.class).toString());
  cellValues.addAll(extraValuesFrom(outcome));
  return cellValues.toArray(OF_STRINGS);
}

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

private String[] withRowDataFrom(TestOutcome outcome) {
  List<? extends Serializable> defaultValues = ImmutableList.of(outcome.getStoryTitle(),
                                 outcome.getTitle(),
                                 outcome.getResult(),
                                 outcome.getStartTime(),
                                 passRateFor(outcome),
                                 outcome.getDurationInSeconds());
  List<String> cellValues = extract(defaultValues, on(Object.class).toString());
  cellValues.addAll(extraValuesFrom(outcome));
  return cellValues.toArray(OF_STRINGS);
}

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

@Override
public String toString() {
  if (!hasChildren()) {
    return description;
  } else {
    String childDescriptions = join(extract(children, on(TestStep.class).toString()));
    return description + " [" + childDescriptions + "]";
  }
}

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

@Override
public String toString() {
  if (!hasChildren()) {
    return description;
  } else {
    String childDescriptions = join(extract(children, on(TestStep.class).toString()));
    return description + " [" + childDescriptions + "]";
  }
}

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

private TestResult overallResultFrom(List<DataTableRow> rows) {
  TestResultList rowResults = TestResultList.of(extract(rows, on(DataTableRow.class).getResult()));
  return rowResults.getOverallResult();
}

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

@Override
public String toString() {
  return getTitle() + ":" + join(extract(testSteps, on(TestStep.class).toString()));
}

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

@Override
public String toString() {
  return getTitle() + ":" + join(extract(testSteps, on(TestStep.class).toString()));
}

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

public List<ScreenshotAndHtmlSource> getScreenshotAndHtmlSources() {
  List<TestStep> testStepsWithScreenshots = select(getFlattenedTestSteps(),
      having(on(TestStep.class).needsScreenshots()));
  return flatten(extract(testStepsWithScreenshots, on(TestStep.class).getScreenshots()));
}

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

public List<ScreenshotAndHtmlSource> getScreenshotAndHtmlSources() {
  List<TestStep> testStepsWithScreenshots = select(getFlattenedTestSteps(),
      having(on(TestStep.class).needsScreenshots()));
  return flatten(extract(testStepsWithScreenshots, on(TestStep.class).getScreenshots()));
}

相关文章