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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Selects all the objects in the given iterable that match the given hamcrest Matcher
  3. * Actually it handles also Maps, Arrays and Iterator by collecting their values.
  4. * Note that this method accepts an Object in order to be used in conjunction with the {@link Lambda#forEach(Iterable)}.
  5. * @param iterable The iterable of objects to be filtered
  6. * @param matcher The hamcrest Matcher used to filter the given iterable
  7. * @return A sublist of the given iterable containing all the objects that match the given hamcrest Matcher
  8. */
  9. public static <T> List<T> select(Object iterable, Matcher<?> matcher) {
  10. return select((Iterator<T>)asIterator(iterable), matcher);
  11. }

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

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

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

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

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

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

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

  1. public List<Screenshot> getScreenshots() {
  2. List<Screenshot> screenshots = new ArrayList<Screenshot>();
  3. List<TestStep> testStepsWithScreenshots = select(getFlattenedTestSteps(),
  4. having(on(TestStep.class).needsScreenshots()));
  5. for (TestStep currentStep : testStepsWithScreenshots) {
  6. screenshots.addAll(screenshotsIn(currentStep));
  7. }
  8. return ImmutableList.copyOf(screenshots);
  9. }

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

  1. public List<Screenshot> getScreenshots() {
  2. List<Screenshot> screenshots = new ArrayList<Screenshot>();
  3. List<TestStep> testStepsWithScreenshots = select(getFlattenedTestSteps(),
  4. having(on(TestStep.class).needsScreenshots()));
  5. for (TestStep currentStep : testStepsWithScreenshots) {
  6. screenshots.addAll(screenshotsIn(currentStep));
  7. }
  8. return ImmutableList.copyOf(screenshots);
  9. }

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

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

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

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

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

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

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

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

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

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

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

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

相关文章