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:com.haulmont.cuba.core.sys.AvailableLocalesFactory.java
@Override public Object build(String string) { if (string == null) return null; return Arrays.stream(string.split(";")).map(item -> item.split("\\|")) .collect(Collectors.toMap(parts -> parts[0], parts -> LocaleUtils.toLocale(parts[1]))); }
From source file:ConcurrentTest.java
@BeforeClass public static void setUpClass() throws IOException { List<HashResultHolder> list = new ObjectMapper().readValue( JacksonJacksumTest.class.getResourceAsStream("/jacksum_image.json"), new TypeReference<List<HashResultHolder>>() { });/* w ww. ja v a 2 s . c om*/ IMAGE_FILE_RESULTS = list.stream() .collect(Collectors.toMap(HashResultHolder::getAlgorithm, Function.identity())); }
From source file:com.github.tddts.jet.oauth.impl.QueryParserImpl.java
@Override public Map<String, String> toMap(List<NameValuePair> pairs) { return pairs.stream().collect(Collectors.toMap(NameValuePair::getName, NameValuePair::getValue)); }
From source file:ru.xxlabaza.popa.pack.comment.CommentRemoveService.java
@Autowired public CommentRemoveService(List<CommentRemover> commentRemovers) { this.commentRemovers = commentRemovers.stream() .collect(Collectors.toMap(CommentRemover::getType, Function.identity())); }
From source file:org.obiba.mica.micaConfig.service.helper.DatasetIdAggregationMetaDataHelper.java
@Cacheable(value = "aggregations-metadata", key = "'dataset'") public Map<String, AggregationMetaDataProvider.LocalizedMetaData> getDatasets() { try {/* ww w . j a va 2 s . co m*/ List<Dataset> datasets = sudo(() -> publishedDatasetService.findAll()); return datasets.stream() .collect(Collectors.toMap(Dataset::getId, d -> new AggregationMetaDataProvider.LocalizedMetaData(d.getAcronym(), d.getName(), d.getClassName()))); } catch (Exception e) { log.debug("Could not build Dataset aggregation metadata {}", e); return Maps.newHashMap(); } }
From source file:org.obiba.mica.micaConfig.service.helper.NetworkIdAggregationMetaDataHelper.java
@Cacheable(value = "aggregations-metadata", key = "'network'") public Map<String, AggregationMetaDataProvider.LocalizedMetaData> getNetworks() { try {/*from ww w.j av a 2 s .c o m*/ List<Network> networks = sudo(() -> publishedNetworkService.findAll()); return networks.stream() .collect(Collectors.toMap(Network::getId, d -> new AggregationMetaDataProvider.LocalizedMetaData(d.getAcronym(), d.getName(), d.getClass().getSimpleName()))); } catch (Exception e) { log.debug("Could not build Network aggregation metadata {}", e); return Maps.newHashMap(); } }
From source file:net.anyflow.lannister.httphandler.Sessions.java
private String liveString() { try {//from w ww . j a va 2 s . c o m return (new ObjectMapper()) .writeValueAsString(Session.NEXUS.map().values().stream().filter(s -> s.isConnected(false)) .collect(Collectors.toMap(Session::clientId, Function.identity()))); } catch (JsonProcessingException e) { logger.error(e.getMessage(), e); return null; } }
From source file:io.knotx.launcher.SystemPropsConfiguration.java
public SystemPropsConfiguration(String identifier) { envConfig = System.getProperties().entrySet().stream() .filter(entry -> onlyPropertyForIdentifier(entry, identifier)) .collect(Collectors.toMap( entry -> StringUtils.substringAfter((String) entry.getKey(), identifier + "."), entry -> new Value((String) entry.getValue()))); }
From source file:Main.java
/** * @param entries//from w ww . j a va 2 s. c o m * the <i>final</i> set of entries to add to the newly created * <i>unmodifiable</i> map * @return an <i>unmodifiable</i> map with all given entries */ @SafeVarargs public static <K, V> Map<K, V> map(Entry<K, V>... entries) { return Collections .unmodifiableMap(Arrays.stream(entries).collect(Collectors.toMap(Entry::getKey, Entry::getValue))); }
From source file:com.karus.danktitles.commands.HelpSubcommand.java
public HelpSubcommand() { commands = new LinkedHashMap<>(DankTitles.instance.getDescription().getCommands().entrySet().stream() .collect(Collectors.toMap((e) -> e.getKey(), (e) -> new MutablePair<>((String) e.getValue().get("permission"), (String) e.getValue().get("usage"))))); }