List of usage examples for java.util.function Function identity
static <T> Function<T, T> identity()
From source file:ru.xxlabaza.popa.pack.compress.CompressService.java
@Autowired
CompressService(List<Compressor> compressors) {
this.compressors = compressors.stream().collect(toMap(Compressor::getSupportedType, Function.identity()));
}
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:net.anyflow.lannister.httphandler.Sessions.java
private String liveString() { try {//w ww .j a v a 2 s.c om 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:cn.edu.zjnu.acm.judge.service.LanguageService.java
public Map<Integer, Language> getAvailableLanguages() { return languageMapper.findAll().stream().collect( Collectors.toMap(Language::getId, Function.identity(), throwOnMerge(), LinkedHashMap::new)); }
From source file:org.ow2.proactive.procci.service.transformer.TransformerManager.java
@Autowired public TransformerManager(List<TransformerProvider> transformerProviders) { transformerPerType = transformerProviders.stream() .collect(Collectors.toMap(TransformerProvider::getType, Function.identity())); }
From source file:io.cloudslang.web.services.FlowsServiceImpl.java
@Override @Cacheable/*from w w w.j av a2 s .c o m*/ public TreeMap<String, FlowVo> getFlows(String classpath) { Collection<File> cpFiles = getCpFiles(classpath); Map<String, FlowVo> flows = cpFiles.stream().map(this::fileToFlowVo) .collect(toMap(FlowVo::getId, Function.identity())); return new TreeMap<>(flows); }
From source file:org.commonjava.indy.promote.model.ValidationCatalogDTOTest.java
@Test public void jsonRoundTrip() throws IOException { ValidationRuleDTO firstRule = readRule("no-snapshots.groovy"); ValidationRuleDTO secondRule = readRule("parsable-pom.groovy"); Map<String, ValidationRuleDTO> rules = Stream.of(firstRule, secondRule) .collect(Collectors.toMap(ValidationRuleDTO::getName, Function.identity())); String rsName = "test"; ValidationRuleSet rs = new ValidationRuleSet(rsName, "remote:.*", Arrays.asList(firstRule.getName(), secondRule.getName()), Collections.emptyMap()); ValidationCatalogDTO in = new ValidationCatalogDTO(true, rules, Collections.singletonMap(rsName, rs)); IndyObjectMapper mapper = new IndyObjectMapper(true); String json = mapper.writeValueAsString(in); ValidationCatalogDTO out = mapper.readValue(json, ValidationCatalogDTO.class); assertThat(out, notNullValue());// w w w . ja va 2s. c om assertThat(out.isEnabled(), equalTo(in.isEnabled())); Map<String, ValidationRuleDTO> outRules = out.getRules(); assertThat(rules, notNullValue()); assertThat(rules.size(), equalTo(2)); assertThat(rules.get(firstRule.getName()), equalTo(firstRule)); assertThat(rules.get(secondRule.getName()), equalTo(secondRule)); Map<String, ValidationRuleSet> outRuleSets = out.getRuleSets(); assertThat(outRuleSets, notNullValue()); assertThat(outRuleSets.size(), equalTo(1)); assertThat(outRuleSets.get(rsName), equalTo(rs)); }
From source file:org.apache.servicecomb.it.ITUtils.java
public static Map<String, MicroserviceInstance> waitMicroserviceReadyAndLimit(String appId, String microserviceName, String strVersionRule, int minInstanceCount) { Map<String, MicroserviceInstance> instances = waitMicroserviceReady(appId, microserviceName, strVersionRule, minInstanceCount);/* w w w. j av a 2 s. c o m*/ return instances.values().stream().sorted(Comparator.comparing(MicroserviceInstance::getInstanceId)) .limit(minInstanceCount) .collect(Collectors.toMap(MicroserviceInstance::getInstanceId, Function.identity())); }
From source file:ru.xxlabaza.popa.AppConfiguration.java
@Bean public Map<Option, Command> commandsMap(List<Command> commands) { return commands.stream().collect(toMap(Command::getOption, Function.identity())); }
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>>() { });// ww w. j av a 2s . c om 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())); }