本文整理匯總了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);
}