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

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

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

Lambda.sort介绍

[英]Sorts all the items in the given iterable on the respective values of 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

/**
 * Sorts all the items in the given iterable on the respective values of 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 {@link Lambda#forEach(Iterable)}.
 * @param iterable The iterable of objects to be sorted
 * @param argument An argument defined using the {@link Lambda#on(Class)} method 
 * @return A List with the same items of the given iterable sorted on the respective value of the given argument
 */
public static <T> List<T> sort(Object iterable, Object argument) {
  return sort(iterable, argument, 0);
}

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

/**
 * Sorts all the items in the given iterable on the respective values of 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 {@link Lambda#forEach(Iterable)}.
 * @param iterable The iterable of objects to be sorted
 * @param argument An argument defined using the {@link Lambda#on(Class)} method
 * @param option  Sorting option e.g.: DESCENDING + IGNORE_CASE
 * @return A List with the same items of the given iterable sorted on the respective value of the given argument
 */
public static <T> List<T> sort(Object iterable, Object argument, int option) {
  return sort(iterable, argument, getStandardComparator(option));
}

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

void doSort(Object argument) {
  setInner((Iterable<? extends T>)Lambda.sort(innerIterable, argument));
}

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

/**
 * @return The list of all of the different tag types that appear in the test outcomes.
 */
public List<String> getTagTypes() {
  Set<String> tagTypes = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    addTagTypesFrom(outcome, tagTypes);
  }
  return sort(ImmutableList.copyOf(tagTypes), on(String.class));
}

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

/**
 * @return The list of all the names of the different tags in these test outcomes
 */
public List<String> getTagNames() {
  Set<String> tags = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    addTagNamesFrom(outcome, tags);
  }
  return sort(ImmutableList.copyOf(tags), on(String.class));
}

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

public List<String> getFirstClassTagTypes() {
  Set<String> tagTypes = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    addTagTypesFrom(outcome, tagTypes);
  }
  tagTypes.remove("version");
  tagTypes.remove("feature");
  tagTypes.remove("story");
  tagTypes.removeAll(getRequirementTagTypes());
  return sort(ImmutableList.copyOf(tagTypes), on(String.class));
}

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

/**
 * @return The list of all the names of the different tags in these test outcomes
 */
public List<String> getTagNames() {
  Set<String> tags = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    addTagNamesFrom(outcome, tags);
  }
  return sort(ImmutableList.copyOf(tags), on(String.class));
}

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

/**
 * @return The list of all of the different tag types that appear in the test outcomes.
 */
public List<String> getTagTypes() {
  Set<String> tagTypes = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    addTagTypesFrom(outcome, tagTypes);
  }
  return sort(ImmutableList.copyOf(tagTypes), on(String.class));
}

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

public List<String> getFirstClassTagTypes() {
  Set<String> tagTypes = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    addTagTypesFrom(outcome, tagTypes);
  }
  tagTypes.remove("version");
  tagTypes.removeAll(getRequirementTagTypes());
  return sort(ImmutableList.copyOf(tagTypes), on(String.class));
}

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

/**
 * @return The list of all the tags associated with a given tag type.
 */
public List<TestTag> getTagsOfType(String tagType) {
  Set<TestTag> tags = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    tags.addAll(tagsOfType(tagType).in(outcome));
  }
  return sort(ImmutableList.copyOf(tags), on(String.class));
}

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

/**
 * @return The list of all the tags associated with a given tag type.
 */
public List<TestTag> getTagsOfType(String tagType) {
  Set<TestTag> tags = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    tags.addAll(tagsOfType(tagType).in(outcome));
  }
  return sort(ImmutableList.copyOf(tags), on(String.class));
}

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

/**
 * @return The list of TestOutcomes contained in this test outcome set.
 */
public List<? extends TestOutcome> getTests() {
  return sort(outcomes, on(TestOutcome.class).getTitle());
}

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

/**
 * @return The list of TestOutcomes contained in this test outcome set.
 */
public List<? extends TestOutcome> getTests() {
  return sort(outcomes, on(TestOutcome.class).getTitle());
}

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

/**
 * @return The list of all the tags associated with a given tag type.
 */
public List<TestTag> getMostSpecificTagsOfType(String tagType) {
  Set<TestTag> tags = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    List<TestTag> mostSpecificOutcomeTags = removeGeneralTagsFrom(tagsOfType(tagType).in(outcome));
    tags.addAll(mostSpecificOutcomeTags);
  }
  return sort(ImmutableList.copyOf(tags), on(String.class));
}

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

public String getFormattedIssues() {
  Set<String> issues = Sets.newHashSet(getIssues());
  if (!issues.isEmpty()) {
    List<String> orderedIssues = sort(issues, on(String.class));
    return "(" + getFormatter().addLinks(StringUtils.join(orderedIssues, ", ")) + ")";
  } else {
    return "";
  }
}

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

/**
 * @return The list of all the tags associated with a given tag type.
 */
public List<TestTag> getMostSpecificTagsOfType(String tagType) {
  Set<TestTag> tags = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    List<TestTag> mostSpecificOutcomeTags = removeGeneralTagsFrom(tagsOfType(tagType).in(outcome));
    tags.addAll(mostSpecificOutcomeTags);
  }
  return sort(ImmutableList.copyOf(tags), on(String.class));
}

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

public String getFormattedIssues() {
  Set<String> issues = Sets.newHashSet(getIssues());
  if (!issues.isEmpty()) {
    List<String> orderedIssues = sort(issues, on(String.class));
    return "(" + getFormatter().addLinks(StringUtils.join(orderedIssues, ", ")) + ")";
  } else {
    return "";
  }
}

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

public List<TestTag> getTagsOfTypeExcluding(String tagType, String excludedTag) {
  Set<TestTag> tags = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    List<TestTag> allTagsOfType = removeGeneralTagsFrom(tagsOfType(tagType).in(outcome));
    allTagsOfType = removeExcluded(allTagsOfType, excludedTag);
    tags.addAll(allTagsOfType);
  }
  return sort(ImmutableList.copyOf(tags), on(String.class));
}

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

public List<TestTag> getTagsOfTypeExcluding(String tagType, String excludedTag) {
  Set<TestTag> tags = Sets.newHashSet();
  for (TestOutcome outcome : outcomes) {
    List<TestTag> allTagsOfType = removeGeneralTagsFrom(tagsOfType(tagType).in(outcome));
    allTagsOfType = removeExcluded(allTagsOfType, excludedTag);
    tags.addAll(allTagsOfType);
  }
  return sort(ImmutableList.copyOf(tags), on(String.class));
}

代码示例来源:origin: dswarm/dswarm

public static List<AttributePathHelper> prepareAttributePathHelpers(final List<AttributePathHelper> attributePaths,
                                  final int level) {
  // only relevant attribute paths
  final List<AttributePathHelper> filteredAttributePaths = Lambda.filter(
      Lambda.having(Lambda.on(AttributePathHelper.class).length(), Matchers.greaterThanOrEqualTo(level)), attributePaths);
  if (filteredAttributePaths == null || filteredAttributePaths.isEmpty()) {
    return null;
  }
  // sort
  return Lambda.sort(filteredAttributePaths, Lambda.on(AttributePathHelper.class).length());
}

相关文章