本文整理匯總了Java中com.google.common.collect.ListMultimap.values方法的典型用法代碼示例。如果您正苦於以下問題:Java ListMultimap.values方法的具體用法?Java ListMultimap.values怎麽用?Java ListMultimap.values使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.ListMultimap
的用法示例。
在下文中一共展示了ListMultimap.values方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLanguages
import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
/**
* Returns the sorted list of languages used in the resources.
*/
@NonNull
public SortedSet<String> getLanguages() {
SortedSet<String> set = new TreeSet<String>();
// As an optimization we could just look for values since that's typically where
// the languages are defined -- not on layouts, menus, etc -- especially if there
// are no translations for it
Set<String> qualifiers = Sets.newHashSet();
synchronized (ITEM_MAP_LOCK) {
for (ListMultimap<String, ResourceItem> map : getMap().values()) {
for (ResourceItem item : map.values()) {
qualifiers.add(item.getQualifiers());
}
}
}
Splitter splitter = Splitter.on('-');
for (String s : qualifiers) {
for (String qualifier : splitter.split(s)) {
if (qualifier.length() == 2 && Character.isLetter(qualifier.charAt(0))
&& Character.isLetter(qualifier.charAt(1))) {
set.add(qualifier);
}
}
}
return set;
}
示例2: getRegions
import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
/**
* Returns the sorted list of regions used in the resources with the given language.
* @param currentLanguage the current language the region must be associated with.
*/
@NonNull
public SortedSet<String> getRegions(@NonNull String currentLanguage) {
SortedSet<String> set = new TreeSet<String>();
// As an optimization we could just look for values since that's typically where
// the languages are defined -- not on layouts, menus, etc -- especially if there
// are no translations for it
Set<String> qualifiers = Sets.newHashSet();
synchronized (ITEM_MAP_LOCK) {
for (ListMultimap<String, ResourceItem> map : getMap().values()) {
for (ResourceItem item : map.values()) {
qualifiers.add(item.getQualifiers());
}
}
}
Splitter splitter = Splitter.on('-');
for (String s : qualifiers) {
boolean rightLanguage = false;
for (String qualifier : splitter.split(s)) {
if (currentLanguage.equals(qualifier)) {
rightLanguage = true;
} else if (rightLanguage
&& qualifier.length() == 3
&& qualifier.charAt(0) == 'r'
&& Character.isUpperCase(qualifier.charAt(1))
&& Character.isUpperCase(qualifier.charAt(2))) {
set.add(qualifier.substring(1));
}
}
}
return set;
}