当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableListMultimap.Builder方法代码示例

本文整理汇总了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);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:29,代码来源:MediaType.java

示例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);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:20,代码来源:MediaType.java

示例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);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:25,代码来源:MediaType.java

示例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();
}
 
开发者ID:greensopinion,项目名称:greenbeans,代码行数:25,代码来源:EntityReferences.java

示例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);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:18,代码来源:MediaType.java

示例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();
}
 
开发者ID:amannocci,项目名称:logbulk,代码行数:21,代码来源:ComponentVerticle.java

示例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);
    }
  }
}
 
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:25,代码来源:MethodHierarchyReader.java

示例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);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:27,代码来源:MediaType.java

示例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);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:19,代码来源:MediaType.java

示例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();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:CollectionUtils.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:Metaservices.java

示例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();
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:30,代码来源:TaskProcessorRegistryImpl.java

示例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());
}
 
开发者ID:inferjay,项目名称:r8,代码行数:10,代码来源:ClassProvider.java

示例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);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:44,代码来源:MediaType.java

示例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);
  }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:43,代码来源:MediaType.java


注:本文中的com.google.common.collect.ImmutableListMultimap.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。