com.google.common.collect.ListMultimap#entries ( )源码实例Demo

下面列出了com.google.common.collect.ListMultimap#entries ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MOE   文件: MetadataScrubber.java
/**
 * A utility method that is useful for stripping a list of words from all the fields of the
 * RevisionMetadata.
 *
 * @param rm the RevisionMetadata to scrub
 * @param words the list of words to replace
 * @param replacement the String to replace the target words with
 * @param wordAlone true if the words to match must surrounded by word boundaries
 * @return a copy representing the RevisionMetadata resulting from the scrub
 */
public static RevisionMetadata stripFromAllFields(
    RevisionMetadata rm, List<String> words, String replacement, boolean wordAlone) {

  String newId = rm.id();
  String newAuthor = rm.author();
  String newDescription = rm.description();
  ListMultimap<String, String> newFields = LinkedListMultimap.create(rm.fields());
  for (String word : words) {
    String regex = (wordAlone) ? ("(?i)(\\b)" + word + "(\\b)") : ("(?i)" + word);
    newId = newId.replaceAll(regex, replacement);
    newAuthor = replaceAuthor(newAuthor, word, replacement);
    newDescription = newDescription.replaceAll(regex, replacement);
    for (Entry<String, String> entry : newFields.entries()) {
      entry.setValue(entry.getValue().replaceAll(regex, replacement));
    }
  }
  return rm.toBuilder()
      .id(newId)
      .author(newAuthor)
      .description(newDescription)
      .fields(ImmutableSetMultimap.copyOf(newFields))
      .build();
}
 
源代码2 项目: che   文件: Service.java
/**
 * This method is the same to {@link #createLinkHeader(Page, String, Map, Object...)} except of
 * receiving multivalued query parameters.
 */
protected String createLinkHeader(
    Page<?> page, String method, ListMultimap<String, Object> queryParams, Object... pathParams) {
  final UriBuilder ub = getServiceContext().getServiceUriBuilder().path(getClass(), method);
  for (Map.Entry<String, Object> queryParam : queryParams.entries()) {
    ub.queryParam(queryParam.getKey(), queryParam.getValue());
  }
  return PagingUtil.createLinkHeader(page, ub.build(pathParams));
}
 
源代码3 项目: NEI-Integration   文件: EntityDumper.java
@Override
public Iterable<String[]> dump(int mode) {
    List<String[]> list = new LinkedList<String[]>();
    
    List<Integer> ids = new ArrayList<Integer>();
    ids.addAll(EntityList.IDtoClassMapping.keySet());
    Collections.sort(ids);
    
    for (int id : ids) {
        list.add(new String[] { GLOBAL, String.valueOf(id), EntityList.getStringFromID(id), EntityList.getClassFromID(id).getName() });
    }
    
    ListMultimap<ModContainer, EntityRegistration> modEntities = ReflectionHelper.getPrivateValue(EntityRegistry.class, EntityRegistry.instance(), "entityRegistrations");
    
    for (Entry<ModContainer, EntityRegistration> e : modEntities.entries()) {
        EntityRegistration er = e.getValue();
        list.add(new String[] { e.getKey().getModId(), String.valueOf(er.getModEntityId()), e.getKey().getModId() + "." + er.getEntityName(), er.getEntityClass().getName() });
    }
    
    Collections.sort(list, new Comparator<String[]>() {
        @Override
        public int compare(String[] s1, String[] s2) {
            if (s1[0].equals(GLOBAL) && !s1[0].equals(s2[0])) {
                return -1;
            }
            int i = s1[0].compareTo(s2[0]);
            if (i != 0) {
                return i;
            }
            return Integer.compare(Integer.valueOf(s1[1]), Integer.valueOf(s2[1]));
        }
    });
    
    return list;
}