本文整理汇总了Java中com.google.common.collect.ImmutableList.sortedCopyOf方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableList.sortedCopyOf方法的具体用法?Java ImmutableList.sortedCopyOf怎么用?Java ImmutableList.sortedCopyOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableList
的用法示例。
在下文中一共展示了ImmutableList.sortedCopyOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ProjectInfo
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@JsonCreator
public ProjectInfo(@JsonProperty("name") String name,
@JsonProperty("repos") List<RepoInfo> repos,
@JsonProperty("members") List<MemberInfo> members,
@JsonProperty("tokens") List<TokenInfo> tokens,
@JsonProperty("creation") UserAndTimestamp creation,
@JsonProperty("removal") @Nullable UserAndTimestamp removal) {
this.name = requireNonNull(name, "name");
this.repos = ImmutableList.sortedCopyOf(Comparator.comparing(RepoInfo::name),
requireNonNull(repos, "repos"));
this.members = ImmutableList.sortedCopyOf(Comparator.comparing(MemberInfo::login),
requireNonNull(members, "members"));
this.tokens = ImmutableList.sortedCopyOf(Comparator.comparing(TokenInfo::appId),
requireNonNull(tokens, "tokens"));
this.creation = requireNonNull(creation, "creation");
this.removal = removal;
}
示例2: should_sort_health_responses
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Test
public void should_sort_health_responses() {
// GIVEN
Sort sort = new Sort(
new Order(ASC, "status"),
new Order(DESC, "totalTimeMillis"),
new Order(ASC, "service")
);
// WHEN
Comparator<HealthResponse> comparator = sortCompare.getComparator(sort);
List<HealthResponse> sorted = ImmutableList.sortedCopyOf(comparator, givenHealthResponses());
// THEN
then(sorted).extracting(HealthResponse::getService).containsExactly("E", "D", "C", "B", "A");
}
示例3: getAllCountries
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@GET
public Collection getAllCountries(@QueryParam("sort") String sort) {
final ImmutableList<Country> sortedCountries;
// Get query parameter
if ("name,desc".equals(sort)) {
sortedCountries = ImmutableList.sortedCopyOf(
(a, b) -> b.getCode().compareTo(a.getCode()), this.countries);
} else {
// default sorting: name (ascending)
sortedCountries = ImmutableList.sortedCopyOf(
(a, b) -> a.getCode().compareTo(b.getCode()), this.countries);
}
return sortedCountries;
}
示例4: AnnotatedDisease
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
/**
* Constructor.
*
* <p>
* The alternative disease names will be sorted on construction.
* </p>
*
* @param diseaseId The disease ID.
* @param name The name of the disease.
* @param alternativeNames Alternative disease names.
* @param positiveAnnotations Positive disease annotations.
* @param negativeAnnotations Negative disease annotations.
*/
public AnnotatedDisease(DiseaseId diseaseId, String name, Collection<String> alternativeNames,
Collection<HpoDiseaseAnnotation> positiveAnnotations,
Collection<HpoDiseaseAnnotation> negativeAnnotations) {
this.diseaseId = diseaseId;
this.name = name;
this.alternativeNames = ImmutableList.sortedCopyOf(alternativeNames);
this.positiveAnnotations = ImmutableList.copyOf(positiveAnnotations);
this.negativeAnnotations = ImmutableList.copyOf(negativeAnnotations);
}