本文整理匯總了Java中com.google.common.collect.ImmutableListMultimap.get方法的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableListMultimap.get方法的具體用法?Java ImmutableListMultimap.get怎麽用?Java ImmutableListMultimap.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.ImmutableListMultimap
的用法示例。
在下文中一共展示了ImmutableListMultimap.get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: modifyTypes
import com.google.common.collect.ImmutableListMultimap; //導入方法依賴的package包/類
/** Applies the supplied modifications to the GraphQLTypes. */
private static BiMap<String, GraphQLType> modifyTypes(
BiMap<String, GraphQLType> mapping,
ImmutableListMultimap<String, TypeModification> modifications) {
BiMap<String, GraphQLType> result = HashBiMap.create(mapping.size());
for (String key : mapping.keySet()) {
if (mapping.get(key) instanceof GraphQLObjectType) {
GraphQLObjectType val = (GraphQLObjectType) mapping.get(key);
if (modifications.containsKey(key)) {
for (TypeModification modification : modifications.get(key)) {
val = modification.apply(val);
}
}
result.put(key, val);
} else {
result.put(key, mapping.get(key));
}
}
return result;
}
示例2: writeDiscovery
import com.google.common.collect.ImmutableListMultimap; //導入方法依賴的package包/類
public Result writeDiscovery(
Iterable<ApiConfig> configs, DiscoveryContext context, SchemaRepository schemaRepository) {
ImmutableListMultimap<ApiKey, ApiConfig> configsByKey = Multimaps.index(configs,
new Function<ApiConfig, ApiKey>() {
@Override public ApiKey apply(ApiConfig config) {
return config.getApiKey();
}
});
ImmutableMap.Builder<ApiKey, RestDescription> builder = ImmutableMap.builder();
// "Default" API versions were determined automagically in legacy endpoints.
// This version only allows to remove an API from default ones by adding
// defaultVersion = AnnotationBoolean.FALSE to @Api
ImmutableSet.Builder<ApiKey> preferred = ImmutableSet.builder();
for (ApiKey apiKey : configsByKey.keySet()) {
ImmutableList<ApiConfig> apiConfigs = configsByKey.get(apiKey);
builder.put(apiKey, writeApi(apiKey, apiConfigs, context, schemaRepository));
// last config takes precedence (same as writeApi)
if (Iterables.getLast(apiConfigs).getIsDefaultVersion()) {
preferred.add(apiKey);
}
}
ImmutableMap<ApiKey, RestDescription> discoveryDocs = builder.build();
return Result.builder()
.setDiscoveryDocs(discoveryDocs)
.setDirectory(generateDirectory(discoveryDocs, preferred.build(), context))
.build();
}
示例3: getEditLogManifest
import com.google.common.collect.ImmutableListMultimap; //導入方法依賴的package包/類
/**
* Return a manifest of what finalized edit logs are available. All available
* edit logs are returned starting from the transaction id passed. If
* 'fromTxId' falls in the middle of a log, that log is returned as well.
*
* @param fromTxId Starting transaction id to read the logs.
* @return RemoteEditLogManifest object.
*/
public synchronized RemoteEditLogManifest getEditLogManifest(long fromTxId) {
// Collect RemoteEditLogs available from each FileJournalManager
List<RemoteEditLog> allLogs = Lists.newArrayList();
for (JournalAndStream j : journals) {
if (j.getManager() instanceof FileJournalManager) {
FileJournalManager fjm = (FileJournalManager)j.getManager();
try {
allLogs.addAll(fjm.getRemoteEditLogs(fromTxId, false));
} catch (Throwable t) {
LOG.warn("Cannot list edit logs in " + fjm, t);
}
}
}
// Group logs by their starting txid
ImmutableListMultimap<Long, RemoteEditLog> logsByStartTxId =
Multimaps.index(allLogs, RemoteEditLog.GET_START_TXID);
long curStartTxId = fromTxId;
List<RemoteEditLog> logs = Lists.newArrayList();
while (true) {
ImmutableList<RemoteEditLog> logGroup = logsByStartTxId.get(curStartTxId);
if (logGroup.isEmpty()) {
// we have a gap in logs - for example because we recovered some old
// storage directory with ancient logs. Clear out any logs we've
// accumulated so far, and then skip to the next segment of logs
// after the gap.
SortedSet<Long> startTxIds = Sets.newTreeSet(logsByStartTxId.keySet());
startTxIds = startTxIds.tailSet(curStartTxId);
if (startTxIds.isEmpty()) {
break;
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Found gap in logs at " + curStartTxId + ": " +
"not returning previous logs in manifest.");
}
logs.clear();
curStartTxId = startTxIds.first();
continue;
}
}
// Find the one that extends the farthest forward
RemoteEditLog bestLog = Collections.max(logGroup);
logs.add(bestLog);
// And then start looking from after that point
curStartTxId = bestLog.getEndTxId() + 1;
}
RemoteEditLogManifest ret = new RemoteEditLogManifest(logs);
if (LOG.isDebugEnabled()) {
LOG.debug("Generated manifest for logs since " + fromTxId + ":"
+ ret);
}
return ret;
}