List of usage examples for java.util.stream Collectors toMap
public static <T, K, U> Collector<T, ?, Map<K, U>> toMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper)
From source file:JacksonJacksumTest.java
@BeforeClass public static void setUpClass() throws IOException { List<HashResultHolder> list = new ObjectMapper().readValue( JacksonJacksumTest.class.getResourceAsStream("/jacksum_image.json"), new TypeReference<List<HashResultHolder>>() { });//from w w w .j a v a 2 s. c o m IMAGE_FILE_RESULTS = list.stream() .collect(Collectors.toMap(HashResultHolder::getAlgorithm, Function.identity())); /*Map<String, String> map = JacksumAPI.getAvailableAlgorithms(); map.keySet().stream() .forEach(cannonicalName -> System.out.println(cannonicalName.toUpperCase()+"(\""+map.get(cannonicalName)+"\",\""+cannonicalName+"\", \"alias\"),")); */ /*JacksumAPI.getAvailableAlgorithms().keySet().stream() .forEach(name -> System.out.println("@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) public String "+name+"FileAlt() {return this.getFileHashValue(this.getChecksum(\""+name+"\", true), FILE);}")); */ // IMAGE_FILE_RESULTS.keySet().stream().forEach(str -> System.out.println("@Test public void test_" + str + "(){this.individualTest(\"" + str + "\");}")); list = new ObjectMapper().readValue(JacksonJacksumTest.class.getResourceAsStream("/jacksum_text.json"), new TypeReference<List<HashResultHolder>>() { }); TEXT_FILE_RESULTS = list.stream() .collect(Collectors.toMap(HashResultHolder::getAlgorithm, Function.identity())); list = new ObjectMapper().readValue(JacksonJacksumTest.class.getResourceAsStream("/jacksum_string.json"), new TypeReference<List<HashResultHolder>>() { }); STRING_RESULTS = list.stream() .collect(Collectors.toMap(HashResultHolder::getAlgorithm, Function.identity())); }
From source file:com.pscnlab.member.services.impl.RoleServiceImpl.java
@Override public Map<Integer, Role> findMapByRoleIds(Set<Integer> roleIdsSet) { List<Role> roles = roleDao.findListByRoleIds(roleIdsSet); if (CollectionUtils.isEmpty(roles)) { return Collections.EMPTY_MAP; }/*from w ww.j a v a 2 s . c o m*/ return roles.stream().collect(Collectors.toMap(Role::getUuidRole, Function.identity())); }
From source file:com.epam.ta.reportportal.info.InfoContributorComposite.java
@Override public void contribute(Info.Builder builder) { builder.withDetail(EXTENSIONS_KEY,/*from w ww . ja v a 2s. c o m*/ infoContributors.stream().map(ExtensionContributor::contribute) .flatMap(map -> map.entrySet().stream()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); }
From source file:com.infinitechaos.vpcviewer.web.rest.dto.VpcDetailDTO.java
public VpcDetailDTO(final Vpc vpc, final List<Subnet> subnets, final List<RouteTable> routeTables) { super(vpc);/* w w w . j av a 2 s.co m*/ final Map<String, SubnetDetailDTO> subnetDetails = new HashMap<>(); subnetDetails.putAll(subnets.stream().map(SubnetDetailDTO::new) .collect(Collectors.toMap(s -> s.getSubnetId(), identity()))); LOG.trace("Details map: {}", subnetDetails); routeTables.stream().map(RouteTableDTO::new).forEach(rt -> rt.getAssociations().forEach(assoc -> { SubnetDetailDTO dto = subnetDetails.get(assoc.getSubnetId()); if (dto == null) { if (LOG.isTraceEnabled()) { LOG.trace("RT: {}, Assoc.SubnetID: {}, Assocs: {}", rt.getRouteTableId(), assoc.getSubnetId(), rt.getAssociations()); } return; } dto.setRouteTableId(rt.getRouteTableId()); dto.getRoutes().addAll(rt.getRoutes()); })); this.subnets.addAll(subnetDetails.values()); }
From source file:com.github.tmyroadctfig.icloud4j.ICloudException.java
/** * Creates a new exception wrapping the original cause. * * @param response the HTTP response.// w w w.ja va2 s.c o m * @param errorMap the map of error values returned by iCloud. */ public ICloudException(HttpResponse response, Map<String, Object> errorMap) { this.errorMap = ImmutableMap.copyOf(errorMap); this.statusLine = response.getStatusLine(); this.headers = Arrays.stream(response.getAllHeaders()) .collect(Collectors.toMap(Header::getName, Header::getValue)); }
From source file:com.netflix.spinnaker.fiat.providers.DefaultApplicationProvider.java
@Override protected Set<Application> loadAll() throws ProviderException { try {/*ww w . j av a 2s . c om*/ Map<String, Application> appByName = front50Service.getAllApplicationPermissions().stream() .collect(Collectors.toMap(Application::getName, Function.identity())); clouddriverService.getApplications().stream().filter(app -> !appByName.containsKey(app.getName())) .forEach(app -> appByName.put(app.getName(), app)); return new HashSet<>(appByName.values()); } catch (Exception e) { throw new ProviderException(this.getClass(), e.getCause()); } }
From source file:com.epam.ta.reportportal.ws.converter.builders.ProjectSettingsResourceBuilder.java
public ProjectSettingsResourceBuilder addProjectSettings(Project settings) { ProjectSettingsResource resource = getObject(); resource.setProjectId(settings.getId()); Map<String, List<IssueSubTypeResource>> result = settings.getConfiguration().getSubTypes().entrySet() .stream()/* www. j a v a2 s . c om*/ .collect(Collectors.toMap(entry -> entry.getKey().getValue(), entry -> entry.getValue().stream() .map(subType -> new IssueSubTypeResource(subType.getLocator(), subType.getTypeRef(), subType.getLongName(), subType.getShortName(), subType.getHexColor())) .collect(Collectors.toList()))); resource.setSubTypes(result); return this; }
From source file:com.github.horrorho.inflatabledonkey.requests.MappedHeaders.java
public MappedHeaders(Collection<Header> headers) { this.headers = headers.stream() .collect(Collectors.toMap(header -> header.getName().toLowerCase(Locale.US), Function.identity())); }
From source file:org.ow2.proactive.connector.iaas.cloud.CloudManager.java
@Autowired public CloudManager(List<CloudProvider> cloudProviders) { cloudProviderPerType = cloudProviders.stream() .collect(Collectors.toMap(CloudProvider::getType, Function.identity())); }
From source file:com.diversityarrays.kdxplore.trialmgr.trait.repair.TraitsToRepair.java
public TraitsToRepair(KdxploreDatabase kdxdb, List<Trait> toBeFixed) { this.kdxdb = kdxdb; this.traits = toBeFixed; Collections.sort(traits);/*from ww w.jav a 2 s .com*/ this.traitById = traits.stream().collect(Collectors.toMap(Trait::getTraitId, Function.identity())); }