Java Code Examples for com.google.common.collect.ListMultimap#entries()
The following examples show how to use
com.google.common.collect.ListMultimap#entries() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetadataScrubber.java From MOE with Apache License 2.0 | 6 votes |
/** * 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(); }
Example 2
Source File: Service.java From che with Eclipse Public License 2.0 | 5 votes |
/** * 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)); }
Example 3
Source File: EntityDumper.java From NEI-Integration with MIT License | 5 votes |
@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; }