本文整理汇总了Java中com.google.common.collect.Multimap.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java Multimap.keySet方法的具体用法?Java Multimap.keySet怎么用?Java Multimap.keySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Multimap
的用法示例。
在下文中一共展示了Multimap.keySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildRecursively
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private List<ConsumerProvidedTaskSelector> buildRecursively(GradleProject project) {
Multimap<String, String> aggregatedTasks = ArrayListMultimap.create();
collectTasks(project, aggregatedTasks);
List<ConsumerProvidedTaskSelector> selectors = Lists.newArrayList();
for (String selectorName : aggregatedTasks.keySet()) {
SortedSet<String> selectorTasks = Sets.newTreeSet(new TaskNameComparator());
selectorTasks.addAll(aggregatedTasks.get(selectorName));
selectors.add(new ConsumerProvidedTaskSelector().
setName(selectorName).
setTaskNames(selectorTasks).
setDescription(project.getParent() != null
? String.format("%s:%s task selector", project.getPath(), selectorName)
: String.format("%s task selector", selectorName)).
setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.getName())));
}
return selectors;
}
示例2: extractDependencies
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/** Looks for dependencies contained in all configurations to remove them from multimap and return as result. */
private List<IdeDependencyKey<?, Dependency>> extractDependencies(Multimap<IdeDependencyKey<?, Dependency>, String> dependenciesToConfigs,
Collection<String> configurations, Collection<String> minusConfigurations) {
List<IdeDependencyKey<?, Dependency>> deps = new ArrayList<IdeDependencyKey<?, Dependency>>();
List<IdeDependencyKey<?, Dependency>> minusDeps = new ArrayList<IdeDependencyKey<?, Dependency>>();
for (IdeDependencyKey<?, Dependency> dependencyKey : dependenciesToConfigs.keySet()) {
if (dependenciesToConfigs.get(dependencyKey).containsAll(configurations)) {
boolean isInMinus = false;
for (String minusConfiguration : minusConfigurations) {
if (dependenciesToConfigs.get(dependencyKey).contains(minusConfiguration)) {
isInMinus = true;
break;
}
}
if (!isInMinus) {
deps.add(dependencyKey);
} else {
minusDeps.add(dependencyKey);
}
}
}
for (IdeDependencyKey<?, Dependency> key : Iterables.concat(deps, minusDeps)) {
dependenciesToConfigs.removeAll(key);
}
return deps;
}
示例3: sortByListSize
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/** Sorts a {@link Multimap} based on the length of each value list */
static public <E extends Comparable<E>, T extends Comparable<T>> TreeMap<T, Collection<E>> sortByListSize(
Multimap<T, E> multimap) {
Comparator<T> comparator = new Comparator<T>() {
@Override
public int compare(T t1, T t2) {
int s1 = multimap.get(t1).size();
int s2 = multimap.get(t2).size();
if (s2 != s1)
return s2 - s1;
return t1.compareTo(t2);
}
};
TreeMap<T, Collection<E>> sortedMap = new TreeMap<>(comparator);
for (T key : multimap.keySet()) {
Collection<E> elems = multimap.get(key);
sortedMap.put(key, elems);
}
return sortedMap;
}
示例4: createOptions
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Turn this Multimap into a two-dimensional array the first index giving the page, second the choices of this page.
*
* @param multimap
* name to many options
* @return two-dim Array of T
*/
public static <T> Object[][] createOptions(Multimap<String, T> multimap) {
Object[][] result = new Object[multimap.keySet().size()][];
int page = 0;
for (String key : multimap.keySet()) {
Collection<T> values = multimap.get(key);
result[page] = new Object[values.size()];
int valueIndex = 0;
for (T value : values) {
result[page][valueIndex] = value;
valueIndex++;
}
page++;
}
return result;
}
示例5: institutionEvent
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
@Override
public void institutionEvent(final InstitutionEvent event)
{
switch( event.getEventType() )
{
case AVAILABLE:
Multimap<Long, Institution> schema2inst = event.getChanges();
Set<Long> schemas = schema2inst.keySet();
for( Long schemaId : schemas )
{
backgroundIndexers.getUnchecked(schemaId).synchronizeFull(schema2inst.get(schemaId));
}
break;
default:
break;
}
}
示例6: loadTypesToValidRolesMap
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private static Multimap<Symbol, Symbol> loadTypesToValidRolesMap(final Parameters params)
throws IOException {
final Multimap<Symbol, Symbol> typesToValidRolesInitial = FileUtils.loadSymbolMultimap(
Files.asCharSource(params.getExistingFile("typeAndRoleFile"), Charsets.UTF_8));
final Set<Symbol> alwaysValidRoles = params.getSymbolSet("alwaysValidRoles");
final ImmutableMultimap.Builder<Symbol, Symbol> typesToValidRolesB = ImmutableMultimap.builder();
typesToValidRolesB.putAll(typesToValidRolesInitial);
for (final Symbol eventType : typesToValidRolesInitial.keySet()) {
typesToValidRolesB.putAll(eventType, alwaysValidRoles);
}
return typesToValidRolesB.build();
}
示例7: joinSelect
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
String joinSelect(Multimap<String, String> columns) {
List<String> selectColumns = new ArrayList<>();
for (String table : columns.keySet()) {
final Collection<String> keyColumns = columns.get(table);
for (String keyColumn : keyColumns) {
selectColumns.add(
String.format("[%s].[%s]", table, keyColumn)
);
}
}
return Joiner.on(", ").join(selectColumns);
}
示例8: logSummaryOfDuplicates
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private void logSummaryOfDuplicates( Multimap<Collection<File>, String> overlapping )
{
for ( Collection<File> jarz : overlapping.keySet() )
{
List<String> jarzS = new LinkedList<String>();
for ( File jjar : jarz )
{
jarzS.add( jjar.getName() );
}
List<String> classes = new LinkedList<String>();
for ( String clazz : overlapping.get( jarz ) )
{
classes.add( clazz.replace( ".class", "" ).replace( "/", "." ) );
}
//CHECKSTYLE_OFF: LineLength
getLogger().warn(
Joiner.on( ", " ).join( jarzS ) + " define " + classes.size() + " overlapping classes: " );
//CHECKSTYLE_ON: LineLength
int max = 10;
for ( int i = 0; i < Math.min( max, classes.size() ); i++ )
{
getLogger().warn( " - " + classes.get( i ) );
}
if ( classes.size() > max )
{
getLogger().warn( " - " + ( classes.size() - max ) + " more..." );
}
}
}
示例9: performAdditionalQueries
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
@Override
public void performAdditionalQueries(ItemSerializerState state)
{
if( state.hasCategory(ItemSerializerService.CATEGORY_ATTACHMENT) )
{
Multimap<Long, Attachment> attachments = itemDao
.getAttachmentsForItemIds(state.getItemIdsWithPrivilege(ItemSecurityConstants.VIEW_ITEM));
for( Long itemId : attachments.keySet() )
{
state.setData(itemId, ALIAS_ATTACHMENTS, attachments.get(itemId));
}
}
}
示例10: regroupPerWays
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private static Set<Long> regroupPerWays(Multimap<Long, SignPostPath> sp) {
Set<Long> result = newHashSet();
for (Long key : sp.keySet()) {
for(SignPostPath signPostPath : sp.get(key)) {
result.add(signPostPath.getTomtomId());
}
}
return result;
}
示例11: dependenciesByLevel
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
public static String dependenciesByLevel(Multimap<Integer, String> instancesByLevel) {
StringBuilder sb = new StringBuilder();
for (Integer key : instancesByLevel.keySet()) {
sb.append("Level ")
.append(key)
.append(": ")
.append(instancesByLevel.get(key))
.append('\n');
}
return sb.toString();
}
示例12: createVariables
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Create one multi-valued variable per column : variableName_[columnName]_[row].
* @param variableManager
* @param valuesForEachColumn
* @param variableName
*/
static void createVariables(VariableManager variableManager, Multimap<String, String> valuesForEachColumn,
String variableName) {
final Set<String> columnNames = valuesForEachColumn.keySet();
int randomRow = -1;
for (final String columnName : columnNames) {
final Iterator<String> valuesIt = valuesForEachColumn.get(columnName).iterator();
int row = 1;
int rowCount = valuesForEachColumn.get(columnName).size();
while (valuesIt.hasNext()) {
final String value = valuesIt.next();
if (row == 1) {
//first row, we set values count
variableManager.setValue(variableName + SEP_VAR + columnName, value);
variableManager.setValue(variableName + SEP_VAR + columnName + SEP_VAR + COUNT_NAME,
Integer.toString(rowCount));
variableManager.setValue(variableName + SEP_VAR + columnName + SEP_VAR + MATCH_NR_NAME,
Integer.toString(rowCount));
}
if (row == 1 && randomRow == -1) {
//first row and first column
variableManager.setValue(variableName, value);
//create a random value between 1 and rowCount
randomRow = RANDOM.nextInt(rowCount) + 1;
}
variableManager.setValue(variableName + SEP_VAR + columnName + SEP_VAR + (row++), value);
}
variableManager.setValue(variableName + SEP_VAR + columnName + SEP_VAR + RAND_NAME,
variableManager.getValue(variableName + SEP_VAR + columnName + SEP_VAR + randomRow));
}
}
示例13: getTotalRowCountAsString
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Get the total of rows retrieved by all queries executed.
* @param columnsForEachSqlStatement
* @param valuesForEachColumn
* @return
*/
static String getTotalRowCountAsString(final Multimap<String, String> columnsForEachSqlStatement,
final Multimap<String, String> valuesForEachColumn) {
int count = 0;
if (columnsForEachSqlStatement == null || valuesForEachColumn == null) {
return Integer.toString(count);
}
for (final String result : columnsForEachSqlStatement.keySet()) {
final String firstColumn = columnsForEachSqlStatement.get(result).iterator().next();
if (valuesForEachColumn.containsKey(firstColumn)) {
count += valuesForEachColumn.get(firstColumn).size();
}
}
return Integer.toString(count);
}
示例14: dumpOverlapProblems
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
public void dumpOverlapProblems(Multimap<byte[], HbckInfo> regions) {
// we display this way because the last end key should be displayed as
// well.
for (byte[] k : regions.keySet()) {
errors.print(Bytes.toStringBinary(k) + ":");
for (HbckInfo r : regions.get(k)) {
errors.print("[ " + r.toString() + ", "
+ Bytes.toStringBinary(r.getEndKey()) + "]");
}
errors.print("----");
}
}
示例15: validateQueryParameters
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private List<ValidationError> validateQueryParameters(final Request request, final Method method) {
final List<ValidationError> validationErrors = new ArrayList<>();
if (disableValidation(request.getHeaders(), ValidationFlag.queryParameter)) {
return validationErrors;
}
final Map<String, TypeDeclaration> queryParamToDeclaration = method.queryParameters().stream()
.collect(Collectors.toMap(TypeDeclaration::name, Function.identity()));
final Map<Pattern, String> queryParamToPattern = method.queryParameters().stream()
.collect(
Collectors.toMap(param -> Pattern.compile(param.name().replaceAll("(<<[^>]+>>)", "[^=]+")), TypeDeclaration::name)
);
final Multimap<String, String> queryParams = ArrayListMultimap.create();
for (final Map.Entry<String, String> queryParam : request.getQueryParams().entrySet()) {
Optional<Map.Entry<Pattern, String>> patternEntry = queryParamToPattern.entrySet().stream().filter(
patternStringEntry -> patternStringEntry.getKey().matcher(queryParam.getKey()).matches()
).findFirst();
if (patternEntry.isPresent()) {
queryParams.put(patternEntry.get().getValue(), queryParam.getValue());
} else {
queryParams.put(queryParam.getKey(), queryParam.getValue());
}
}
for (final String queryParamName : queryParams.keySet()) {
String declarationMatch = queryParamToDeclaration.keySet().stream().filter(s -> {
final String pattern = s.startsWith("/") && s.endsWith("/") ? s.substring(1, s.length() - 1) : s;
return queryParamName.matches(pattern);
}).findFirst().orElse(null);
if (queryParamToDeclaration.containsKey(declarationMatch)) {
final TypeDeclaration queryParamDeclaration = queryParamToDeclaration.get(declarationMatch);
for (final String queryParamValue : queryParams.get(queryParamName)) {
final String validationContext = String.join("=", queryParamName, queryParamValue);
final List<ValidationError> errors = validate(queryParamValue, queryParamDeclaration, ValidationKind.queryParameter, validationContext);
validationErrors.addAll(errors);
}
} else {
validationErrors.add(new ValidationError(ValidationKind.queryParameter, queryParamName, "Unknown query parameter"));
}
}
validationErrors.addAll(method.queryParameters().stream()
.filter(TypeDeclaration::required)
.map(TypeDeclaration::name)
.filter(queryParamName -> !queryParams.containsKey(queryParamName))
.map(queryParamName -> new ValidationError(ValidationKind.queryParameter, queryParamName, "Required query parameter missing"))
.collect(Collectors.toList()));
return validationErrors;
}