本文整理汇总了Java中com.google.common.collect.ImmutableListMultimap.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableListMultimap.Builder方法的具体用法?Java ImmutableListMultimap.Builder怎么用?Java ImmutableListMultimap.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableListMultimap
的用法示例。
在下文中一共展示了ImmutableListMultimap.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: withParameter
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/**
* <em>Replaces</em> all parameters with the given attribute with a single parameter with the
* given value. If multiple parameters with the same attributes are necessary use
* {@link #withParameters}. Prefer {@link #withCharset} for setting the {@code charset} parameter
* when using a {@link Charset} object.
*
* @throws IllegalArgumentException if either {@code attribute} or {@code value} is invalid
*/
public MediaType withParameter(String attribute, String value) {
checkNotNull(attribute);
checkNotNull(value);
String normalizedAttribute = normalizeToken(attribute);
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
for (Entry<String, String> entry : parameters.entries()) {
String key = entry.getKey();
if (!normalizedAttribute.equals(key)) {
builder.put(key, entry.getValue());
}
}
builder.put(normalizedAttribute, normalizeParameterValue(normalizedAttribute, value));
MediaType mediaType = new MediaType(type, subtype, builder.build());
// if the attribute isn't charset, we can just inherit the current parsedCharset
if (!normalizedAttribute.equals(CHARSET_ATTRIBUTE)) {
mediaType.parsedCharset = this.parsedCharset;
}
// Return one of the constants if the media type is a known type.
return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
示例2: create
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
private static MediaType create(
String type, String subtype, Multimap<String, String> parameters) {
checkNotNull(type);
checkNotNull(subtype);
checkNotNull(parameters);
String normalizedType = normalizeToken(type);
String normalizedSubtype = normalizeToken(subtype);
checkArgument(
!WILDCARD.equals(normalizedType) || WILDCARD.equals(normalizedSubtype),
"A wildcard type cannot be used with a non-wildcard subtype");
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
for (Entry<String, String> entry : parameters.entries()) {
String attribute = normalizeToken(entry.getKey());
builder.put(attribute, normalizeParameterValue(attribute, entry.getValue()));
}
MediaType mediaType = new MediaType(normalizedType, normalizedSubtype, builder.build());
// Return one of the constants if the media type is a known type.
return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
示例3: withParameter
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/**
* <em>Replaces</em> all parameters with the given attribute with a single parameter with the
* given value. If multiple parameters with the same attributes are necessary use
* {@link #withParameters}. Prefer {@link #withCharset} for setting the {@code charset} parameter
* when using a {@link Charset} object.
*
* @throws IllegalArgumentException if either {@code attribute} or {@code value} is invalid
*/
public MediaType withParameter(String attribute, String value) {
checkNotNull(attribute);
checkNotNull(value);
String normalizedAttribute = normalizeToken(attribute);
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
for (Entry<String, String> entry : parameters.entries()) {
String key = entry.getKey();
if (!normalizedAttribute.equals(key)) {
builder.put(key, entry.getValue());
}
}
builder.put(normalizedAttribute, normalizeParameterValue(normalizedAttribute, value));
MediaType mediaType = new MediaType(type, subtype, builder.build());
// Return one of the constants if the media type is a known type.
return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
示例4: readEntityReferences
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
private static ListMultimap<String, String> readEntityReferences() {
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
EntityReferences.class.getResourceAsStream("entity-references.txt"), Charsets.UTF_8)); //$NON-NLS-1$
try {
Splitter splitter = Splitter.on(CharMatcher.WHITESPACE).trimResults().omitEmptyStrings();
String line;
while ((line = reader.readLine()) != null) {
List<String> lineItems = splitter.splitToList(line);
checkState(lineItems.size() > 1);
for (int x = 1; x < lineItems.size(); ++x) {
builder.put(lineItems.get(0), lineItems.get(x));
}
}
} finally {
reader.close();
}
} catch (IOException e) {
throw Throwables.propagate(e);
}
return builder.build();
}
示例5: create
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
private static MediaType create(String type, String subtype, Multimap<String, String> parameters) {
checkNotNull(type);
checkNotNull(subtype);
checkNotNull(parameters);
String normalizedType = normalizeToken(type);
String normalizedSubtype = normalizeToken(subtype);
checkArgument(!WILDCARD.equals(normalizedType) || WILDCARD.equals(normalizedSubtype),
"A wildcard type cannot be used with a non-wildcard subtype");
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
for (Entry<String, String> entry : parameters.entries()) {
String attribute = normalizeToken(entry.getKey());
builder.put(attribute, normalizeParameterValue(attribute, entry.getValue()));
}
MediaType mediaType = new MediaType(normalizedType, normalizedSubtype, builder.build());
// Return one of the constants if the media type is a known type.
return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
示例6: start
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
@Override public void start() {
this.config = config();
eventBus = vertx.eventBus();
fallback = config.getString(AppConfig.FALLBACK, StringUtils.EMPTY);
endpoint(config);
releaseOne = new JsonArray().add(endpoint);
// Settings
JsonObject settings = new Configuration(config.getJsonObject(AppConfig.SETTING, new JsonObject()));
tracing = settings.getBoolean(AppConfig.TRACING, false);
// Generate routing
JsonObject routes = config.getJsonObject(AppConfig.ROUTE);
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
for (String route : routes.fieldNames()) {
builder.putAll(route, Streams.to(routes.getJsonArray(route).stream(), String.class)
.collect(Collectors.toList()));
}
routing = builder.build();
}
示例7: buildServiceMethods
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/**
* Recursively builds a map from method_names to methods. Method types will be resolved as much
* as possible using {@code serviceType}.
*
* @param serviceType is the class object being inspected for service methods
*/
private void buildServiceMethods(
ImmutableListMultimap.Builder<EndpointMethod.ResolvedSignature, EndpointMethod> builder,
TypeToken<?> serviceType) {
for (TypeToken<?> typeToken : serviceType.getTypes().classes()) {
Class<?> serviceClass = typeToken.getRawType();
if (Object.class.equals(serviceClass)) {
return;
}
for (Method method : serviceClass.getDeclaredMethods()) {
if (!isServiceMethod(method)) {
continue;
}
EndpointMethod currentMethod = EndpointMethod.create(endpointClass, method, typeToken);
builder.put(currentMethod.getResolvedMethodSignature(), currentMethod);
}
}
}
示例8: withParameter
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/**
* <em>Replaces</em> all parameters with the given attribute with a single parameter with the
* given value. If multiple parameters with the same attributes are necessary use
* {@link #withParameters}. Prefer {@link #withCharset} for setting the {@code charset} parameter
* when using a {@link Charset} object.
*
* @throws IllegalArgumentException if either {@code attribute} or {@code value} is invalid
*/
public MediaType withParameter(String attribute, String value) {
checkNotNull(attribute);
checkNotNull(value);
String normalizedAttribute = normalizeToken(attribute);
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
for (Entry<String, String> entry : parameters.entries()) {
String key = entry.getKey();
if (!normalizedAttribute.equals(key)) {
builder.put(key, entry.getValue());
}
}
builder.put(normalizedAttribute, normalizeParameterValue(normalizedAttribute, value));
MediaType mediaType = new MediaType(type, subtype, builder.build());
// Return one of the constants if the media type is a known type.
return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
示例9: create
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
private static MediaType create(String type, String subtype, Multimap<String, String> parameters) {
checkNotNull(type);
checkNotNull(subtype);
checkNotNull(parameters);
String normalizedType = normalizeToken(type);
String normalizedSubtype = normalizeToken(subtype);
checkArgument(
!WILDCARD.equals(normalizedType) || WILDCARD.equals(normalizedSubtype),
"A wildcard type cannot be used with a non-wildcard subtype");
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
for (Entry<String, String> entry : parameters.entries()) {
String attribute = normalizeToken(entry.getKey());
builder.put(attribute, normalizeParameterValue(attribute, entry.getValue()));
}
MediaType mediaType = new MediaType(normalizedType, normalizedSubtype, builder.build());
// Return one of the constants if the media type is a known type.
return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
示例10: groupBy
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
public static <K, V> ImmutableListMultimap<K, V> groupBy(Iterable<? extends V> iterable, Transformer<? extends K, V> grouper) {
ImmutableListMultimap.Builder<K, V> builder = ImmutableListMultimap.builder();
for (V element : iterable) {
K key = grouper.transform(element);
builder.put(key, element);
}
return builder.build();
}
示例11: allMetaservices
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
ListMultimap<String, String> allMetaservices() {
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
for (Element element : round().getElementsAnnotatedWith(Metainf.Service.class)) {
@Nullable TypeElement typeElement = validated(element);
if (typeElement == null) {
continue;
}
Set<String> interfaceNames = extractServiceInterfaceNames(typeElement);
String binaryName = processing().getElementUtils().getBinaryName(typeElement).toString();
builder.putAll(binaryName, interfaceNames);
}
return builder.build();
}
示例12: init
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
@PostConstruct
public void init() {
ImmutableListMultimap.Builder<String, Pair<Class<?>, TaskProcessor>> builder = ImmutableListMultimap.builder();
taskProcessors.forEach(processor ->
Stream.of(processor.getClass().getGenericInterfaces())
.filter(ParameterizedType.class::isInstance)
.map(ParameterizedType.class::cast)
.filter(iface -> iface.getRawType() != null && TaskProcessor.class.getName().equals(iface.getRawType().getTypeName()))
.map(iface -> iface.getActualTypeArguments()[0].getTypeName())
.findFirst()
.ifPresent(taskClassName -> {
Class<?> taskClass = JavaUtils.callWithoutCheckedException(() -> Class.forName(taskClassName));
CamundaTask camundaTask = taskClass.getAnnotation(CamundaTask.class);
if (camundaTask == null) {
LOG.warn("Task processor [{}] processes task class [{}] without annotation [{}]"
, processor.getClass().getName(), taskClassName, CamundaTask.class.getName());
return;
}
String taskName = camundaTask.value();
if (Strings.isNullOrEmpty(taskName)) {
taskName = taskClass.getName();
}
LOG.debug("Register processor [{}] for task [{}]", processor.getClass().getName(), taskName);
builder.put(taskName, Pair.of(taskClass, processor));
})
);
taskProcessorMap = builder.build();
}
示例13: forPreloadedClasses
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/** Create class provider for preloaded classes, classes may have conflicting names. */
public static <T extends DexClass> ClassProvider<T> forPreloadedClasses(
ClassKind classKind, Collection<T> classes) {
ImmutableListMultimap.Builder<DexType, T> builder = ImmutableListMultimap.builder();
for (T clazz : classes) {
builder.put(clazz.type, clazz);
}
return new PreloadedClassProvider<>(classKind, builder.build());
}
示例14: parse
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/**
* Parses a media type from its string representation.
*
* @throws IllegalArgumentException if the input is not parsable
*/
public static MediaType parse(String input) {
checkNotNull(input);
Tokenizer tokenizer = new Tokenizer(input);
try {
String type = tokenizer.consumeToken(TOKEN_MATCHER);
tokenizer.consumeCharacter('/');
String subtype = tokenizer.consumeToken(TOKEN_MATCHER);
ImmutableListMultimap.Builder<String, String> parameters = ImmutableListMultimap.builder();
while (tokenizer.hasMore()) {
tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
tokenizer.consumeCharacter(';');
tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
String attribute = tokenizer.consumeToken(TOKEN_MATCHER);
tokenizer.consumeCharacter('=');
final String value;
if ('"' == tokenizer.previewChar()) {
tokenizer.consumeCharacter('"');
StringBuilder valueBuilder = new StringBuilder();
while ('"' != tokenizer.previewChar()) {
if ('\\' == tokenizer.previewChar()) {
tokenizer.consumeCharacter('\\');
valueBuilder.append(tokenizer.consumeCharacter(ascii()));
} else {
valueBuilder.append(tokenizer.consumeToken(QUOTED_TEXT_MATCHER));
}
}
value = valueBuilder.toString();
tokenizer.consumeCharacter('"');
} else {
value = tokenizer.consumeToken(TOKEN_MATCHER);
}
parameters.put(attribute, value);
}
return create(type, subtype, parameters.build());
} catch (IllegalStateException e) {
throw new IllegalArgumentException("Could not parse '" + input + "'", e);
}
}
示例15: parse
import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/**
* Parses a media type from its string representation.
*
* @throws IllegalArgumentException if the input is not parsable
*/
public static MediaType parse(String input) {
checkNotNull(input);
Tokenizer tokenizer = new Tokenizer(input);
try {
String type = tokenizer.consumeToken(TOKEN_MATCHER);
tokenizer.consumeCharacter('/');
String subtype = tokenizer.consumeToken(TOKEN_MATCHER);
ImmutableListMultimap.Builder<String, String> parameters = ImmutableListMultimap.builder();
while (tokenizer.hasMore()) {
tokenizer.consumeCharacter(';');
tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
String attribute = tokenizer.consumeToken(TOKEN_MATCHER);
tokenizer.consumeCharacter('=');
final String value;
if ('"' == tokenizer.previewChar()) {
tokenizer.consumeCharacter('"');
StringBuilder valueBuilder = new StringBuilder();
while ('"' != tokenizer.previewChar()) {
if ('\\' == tokenizer.previewChar()) {
tokenizer.consumeCharacter('\\');
valueBuilder.append(tokenizer.consumeCharacter(ascii()));
} else {
valueBuilder.append(tokenizer.consumeToken(QUOTED_TEXT_MATCHER));
}
}
value = valueBuilder.toString();
tokenizer.consumeCharacter('"');
} else {
value = tokenizer.consumeToken(TOKEN_MATCHER);
}
parameters.put(attribute, value);
}
return create(type, subtype, parameters.build());
} catch (IllegalStateException e) {
throw new IllegalArgumentException("Could not parse '" + input + "'", e);
}
}