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

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

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

Lambda.select介绍

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

代码示例

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

/**
 * Filters all the objects in the given iterable that match the given hamcrest Matcher
 * @param matcher The hamcrest Matcher used to filter the given iterable
 * @param iterable The iterable of objects to be filtered
 * @return A sublist of the given iterable containing all the objects that match the given hamcrest Matcher
 */
public static <T> List<T> filter(Matcher<?> matcher, Iterable<T> iterable) {
  return select(iterable, matcher);
}

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

/**
 * Filters all the objects in the given array that match the given hamcrest Matcher
 * @param matcher The hamcrest Matcher used to filter the given array
 * @param array The array of objects to be filtered
 * @return A sublist of the given array containing all the objects that match the given hamcrest Matcher
 */
public static <T> List<T> filter(Matcher<?> matcher, T... array) {
  return select(array, matcher);
}

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

/**
 * Selects all the objects in the given iterable that match the given hamcrest Matcher
 * @param iterable The iterable of objects to be filtered
 * @param matcher The hamcrest Matcher used to filter the given iterable
 * @return A sublist of the given iterable containing all the objects that match the given hamcrest Matcher
 */
public static <T> List<T> select(Iterable<T> iterable, Matcher<?> matcher) {
  if (iterable == null) return new LinkedList<T>();
  return select(iterable.iterator(), matcher);
}

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

private int countTestRunsByResultInLast(TestResult testResult, int testRunCount, List<TestResult> testResults) {
  List<TestResult> eligableTestResults = mostRecent(testRunCount, testResults);
  List<TestResult> successfulTestResults = select(eligableTestResults, is(testResult));
  return successfulTestResults.size();
}

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

private int countSuccessfulTestRunsInLast(int testRunCount, List<TestResult> testResults) {
  List<TestResult> eligableTestResults = mostRecent(testRunCount, testResults);
  List<TestResult> successfulTestResults = select(eligableTestResults, is(TestResult.SUCCESS));
  return successfulTestResults.size();
}

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

private int countTestRunsByResultInLast(TestResult testResult, int testRunCount, List<TestResult> testResults) {
  List<TestResult> eligableTestResults = mostRecent(testRunCount, testResults);
  List<TestResult> successfulTestResults = select(eligableTestResults, is(testResult));
  return successfulTestResults.size();
}

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

private int countSuccessfulTestRunsInLast(int testRunCount, List<TestResult> testResults) {
  List<TestResult> eligableTestResults = mostRecent(testRunCount, testResults);
  List<TestResult> successfulTestResults = select(eligableTestResults, is(TestResult.SUCCESS));
  return successfulTestResults.size();
}

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

/**
 * Selects all the objects in the given iterable that match the given hamcrest Matcher
 * 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 to be filtered
 * @param matcher The hamcrest Matcher used to filter the given iterable
 * @return A sublist of the given iterable containing all the objects that match the given hamcrest Matcher
 */
public static <T> List<T> select(Object iterable, Matcher<?> matcher) {
  return select((Iterator<T>)asIterator(iterable), matcher);
}

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

void doRetain(Matcher<?> matcher) {
  setInner(Lambda.select(innerIterable, matcher));
}

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

void doRemove(Matcher<?> matcher) {
  setInner(Lambda.select(innerIterable, not(matcher)));
}

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

/**
 * Transforms the subset of objects in this iterable that match the given Mathcer
 * in a single object having the same methods of a single object in this iterable.
 * That allows to invoke a method on each T in the collection with a single strong typed method call.
 * The actual class of T is inferred from the class of the first iterable's item, but you can
 * specify a particular class by using the overloaded method.
 * @return An object that proxies all the item in the iterator or null if the iterator is null or empty
 */
public T forEach(Matcher<?> matcher) {
  return Lambda.forEach((List<T>)Lambda.select(getInner(), matcher));
}

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

public List<Screenshot> getScreenshots() {
  List<Screenshot> screenshots = new ArrayList<Screenshot>();
  List<TestStep> testStepsWithScreenshots = select(getFlattenedTestSteps(),
      having(on(TestStep.class).needsScreenshots()));
  for (TestStep currentStep : testStepsWithScreenshots) {
    screenshots.addAll(screenshotsIn(currentStep));
  }
  return ImmutableList.copyOf(screenshots);
}

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

public List<Screenshot> getScreenshots() {
  List<Screenshot> screenshots = new ArrayList<Screenshot>();
  List<TestStep> testStepsWithScreenshots = select(getFlattenedTestSteps(),
      having(on(TestStep.class).needsScreenshots()));
  for (TestStep currentStep : testStepsWithScreenshots) {
    screenshots.addAll(screenshotsIn(currentStep));
  }
  return ImmutableList.copyOf(screenshots);
}

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

public Integer getPendingCount() {
  List<TestStep> allTestSteps = getLeafTestSteps();
  return select(allTestSteps, having(on(TestStep.class).isPending())).size();
}

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

public Integer getPendingCount() {
  List<TestStep> allTestSteps = getLeafTestSteps();
  return select(allTestSteps, having(on(TestStep.class).isPending())).size();
}

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

/**
 * Creates a new MRSUser
 *
 * @param mrsUser Instance of the User object to be saved
 * @return A Map containing saved user's data
 * @throws UserAlreadyExistsException Thrown if the user already exists
 */
@Override
public Map<String, Object> saveUser(MRSUser mrsUser) throws UserAlreadyExistsException {
  MRSPerson person = mrsUser.getPerson();
  List<MRSAttribute> filteredItems = select(person.getAttributes(), having(on(MRSAttribute.class).getName(), equalTo("Email")));
  String email = CollectionUtils.isNotEmpty(filteredItems) ? filteredItems.get(0).getValue() : null;
  MRSUser userByUserName = getUserByUserName(email);
  if (userByUserName != null && !isSystemAdmin(userByUserName.getSystemId())) {
    throw new UserAlreadyExistsException();
  }
  return save(mrsUser);
}

代码示例来源: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()));
}

代码示例来源: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: org.motechproject/motech-openmrs-api

} else {
  final List<Location> locationsWithSameName = locationService.getLocations(facility.getName());
  final List<Location> matchedLocation = Lambda.select(locationsWithSameName, having(on(Location.class), locationMatcher(facility)));
  if (CollectionUtils.isNotEmpty(matchedLocation)) {
    location = matchedLocation.get(0);

相关文章