List of usage examples for com.google.common.collect Multimap put
boolean put(@Nullable K key, @Nullable V value);
From source file:eu.tomylobo.routes.util.Ini.java
public static void saveVector(Multimap<String, String> section, String format, Vector vector) { section.put(String.format(format, "x"), (String.valueOf(vector.getX()))); section.put(String.format(format, "y"), (String.valueOf(vector.getY()))); section.put(String.format(format, "z"), (String.valueOf(vector.getZ()))); }
From source file:scoutdoc.main.check.CheckstyleFileWriter.java
public static void write(List<Check> list, PrintWriter w) { w.println(XML_VERSION);// w ww. ja v a2 s . c o m w.println(CHECKSTYLE_OPEN); Multimap<String, Check> multimap = ArrayListMultimap.create(); for (Check check : list) { String filePath = PageUtility.toFile(check.getPage()).getAbsolutePath(); multimap.put(filePath, check); } for (String file : multimap.keySet()) { w.println("<file name=\"" + file + "\">"); for (Check check : multimap.get(file)) { w.print("<error"); w.print(" line=\"" + check.getLine() + "\""); w.print(" column=\"" + check.getColumn() + "\""); w.print(" severity=\"" + Objects.firstNonNull(check.getSeverity(), "") + "\""); w.print(" message=\"" + Strings.nullToEmpty(check.getMessage()) + "\""); w.print(" source=\"" + Strings.nullToEmpty(check.getSource()) + "\""); w.println("/>"); } w.println(FILE_CLOSE); } w.println(CHECKSTYLE_CLOSE); }
From source file:gobblin.util.PublisherUtils.java
/** * Creates a {@link Multimap} that maps {@link Extract} to their corresponds {@link WorkUnitState}s. * * @see Multimap/* www. jav a 2s . c om*/ */ public static Multimap<Extract, WorkUnitState> createExtractToWorkUnitStateMap( Collection<? extends WorkUnitState> workUnitStates) { Multimap<Extract, WorkUnitState> extractToWorkUnitStateMap = ArrayListMultimap.create(); for (WorkUnitState workUnitState : workUnitStates) { extractToWorkUnitStateMap.put(workUnitState.getExtract(), workUnitState); } return extractToWorkUnitStateMap; }
From source file:org.sonar.batch.issue.tracking.FileHashes.java
public static FileHashes create(String[] hashes) { int size = hashes.length; Multimap<String, Integer> linesByHash = LinkedHashMultimap.create(); for (int i = 0; i < size; i++) { // indices in array are shifted one line before linesByHash.put(hashes[i], i + 1); }//from w w w. j a va 2s.c om return new FileHashes(hashes, linesByHash); }
From source file:org.raml.jaxrs.generator.ResourceUtils.java
public static void fillInBodiesAndResponses(GResource resource, Multimap<GMethod, GRequest> incomingBodies, Multimap<GMethod, GResponse> responses) { for (GMethod method : resource.methods()) { if (method.body().size() == 0) { incomingBodies.put(method, null); } else {//from w w w.jav a 2s . c o m for (GRequest typeDeclaration : method.body()) { incomingBodies.put(method, typeDeclaration); } } if (method.responses().size() == 0) { incomingBodies.put(method, null); } else { for (GResponse response : method.responses()) { responses.put(method, response); } } } }
From source file:com.google.publicalerts.cap.testing.CapTestUtil.java
/** * Asserts that the {@code expected} matches {@code actual}, where equality * between {@link Reason} objects is guaranteed if two objects have same: * <ul>//from w ww.j av a2s . c o m * <li>reason type, * <li>XPath. * </ul> */ public static void assertReasons(Reasons actual, Reason... expected) { Multimap<Reason.Type, String> expectedReasonTypeToXPath = HashMultimap.create(); for (Reason reason : expected) { expectedReasonTypeToXPath.put(reason.getType(), reason.getXPath()); } String msg = ""; boolean failed = false; for (Reason reason : actual) { if (!expectedReasonTypeToXPath.remove(reason.getType(), reason.getXPath())) { msg += " Unexpected reason: " + reason; failed = true; } } for (Entry<Reason.Type, String> expectedEntry : expectedReasonTypeToXPath.entries()) { msg += " Expected reason with type: " + expectedEntry.getKey() + " and XPath: " + expectedEntry.getValue(); failed = true; } Assert.assertFalse(msg, failed); }
From source file:org.sonar.server.permission.ws.template.TemplateUsersAction.java
private static WsPermissions.UsersWsResponse buildResponse(List<UserDto> users, List<PermissionTemplateUserDto> permissionTemplateUsers, Paging paging) { Multimap<Integer, String> permissionsByUserId = TreeMultimap.create(); permissionTemplateUsers.forEach(userPermission -> permissionsByUserId.put(userPermission.getUserId(), userPermission.getPermission())); UsersWsResponse.Builder responseBuilder = UsersWsResponse.newBuilder(); users.forEach(user -> {//from www . jav a2s .com WsPermissions.User.Builder userResponse = responseBuilder.addUsersBuilder().setLogin(user.getLogin()) .addAllPermissions(permissionsByUserId.get(user.getId())); setNullable(user.getEmail(), userResponse::setEmail); setNullable(user.getName(), userResponse::setName); }); responseBuilder.getPagingBuilder().setPageIndex(paging.pageIndex()).setPageSize(paging.pageSize()) .setTotal(paging.total()).build(); return responseBuilder.build(); }
From source file:com.zimbra.soap.adminext.type.Attr.java
public static Multimap<String, String> toMultimap(List<Attr> attrs) { Multimap<String, String> map = ArrayListMultimap.create(); if (attrs != null) { for (Attr a : attrs) { map.put(a.getName(), a.getValue()); }// www . j av a2 s .co m } return map; }
From source file:org.sonar.plugins.pitest.Mutant.java
public static String toJSON(List<Mutant> mutants) { Multimap<Integer, String> mutantsByLine = ArrayListMultimap.create(); for (Mutant mutant : mutants) { mutantsByLine.put(mutant.getLineNumber(), mutant.toJSON()); }// w ww. j a va2 s .c o m StringBuilder builder = new StringBuilder(); builder.append("{"); boolean first = true; for (int line : mutantsByLine.keySet()) { if (!first) { builder.append(","); } first = false; builder.append("\""); builder.append(line); builder.append("\":["); builder.append(Joiner.on(",").join(mutantsByLine.get(line))); builder.append("]"); } builder.append("}"); return builder.toString(); }
From source file:org.sonar.server.permission.ws.TemplateGroupsAction.java
private static WsPermissions.WsGroupsResponse buildResponse(List<GroupDto> groups, List<PermissionTemplateGroupDto> groupPermissions, Paging paging) { Multimap<Long, String> permissionsByGroupId = TreeMultimap.create(); groupPermissions.forEach(groupPermission -> permissionsByGroupId.put(groupPermission.getGroupId(), groupPermission.getPermission())); WsPermissions.WsGroupsResponse.Builder response = WsPermissions.WsGroupsResponse.newBuilder(); groups.forEach(group -> {/*from w w w . j a v a 2 s.c o m*/ WsPermissions.Group.Builder wsGroup = response.addGroupsBuilder().setName(group.getName()); if (group.getId() != 0L) { wsGroup.setId(String.valueOf(group.getId())); } if (group.getDescription() != null) { wsGroup.setDescription(group.getDescription()); } wsGroup.addAllPermissions(permissionsByGroupId.get(group.getId())); }); response.getPagingBuilder().setPageIndex(paging.pageIndex()).setPageSize(paging.pageSize()) .setTotal(paging.total()); return response.build(); }