List of usage examples for java.util.stream Collectors toSet
public static <T> Collector<T, ?, Set<T>> toSet()
From source file:io.gravitee.repository.redis.management.internal.impl.UserRedisRepositoryImpl.java
@Override public Set<RedisUser> find(List<String> users) { return redisTemplate.opsForHash().multiGet(REDIS_KEY, Collections.unmodifiableCollection(users)).stream() .filter(Objects::nonNull).map(o -> this.convert(o, RedisUser.class)).collect(Collectors.toSet()); }
From source file:com.vsct.dt.strowgr.admin.repository.consul.mapping.json.CommittingConfigurationJson.java
@JsonCreator public CommittingConfigurationJson(@JsonProperty("correlationId") String correlationId, @JsonProperty("haproxy") String haproxy, @JsonProperty("haproxyVersion") String haproxyVersion, @JsonProperty("bindingId") int bindingId, @JsonProperty("hapUser") String hapUser, @JsonProperty("frontends") Set<EntryPointFrontendMappingJson> frontends, @JsonProperty("backends") Set<EntryPointBackendMappingJson> backends, @JsonProperty("context") Map<String, String> context) { super(haproxy, hapUser, haproxyVersion, bindingId, frontends.stream().map(identity()).collect(Collectors.toSet()), backends.stream().map(identity()).collect(Collectors.toSet()), context); this.correlationId = correlationId; }
From source file:com.synopsys.integration.blackduck.service.model.ComponentVersionStatusCount.java
public ComponentVersionStatusCount(final NameValuePairView nameValuePair) { final Set<PolicySummaryStatusType> policyStatusTypes = EnumSet.allOf(PolicySummaryStatusType.class); final Set<String> policyStatusTypeValues = policyStatusTypes.stream().map(Object::toString) .collect(Collectors.toSet()); if (policyStatusTypeValues.contains(nameValuePair.getName())) { name = PolicySummaryStatusType.valueOf(nameValuePair.getName()); }//w ww. j a v a2s .c om if (nameValuePair.getValue() != null) { final String valueString = nameValuePair.getValue().toString(); if (NumberUtils.isCreatable(valueString)) { value = NumberUtils.createNumber(valueString).intValue(); } } }
From source file:io.gravitee.repository.redis.management.RedisSubscriptionRepository.java
@Override public Set<Subscription> findByPlan(String plan) throws TechnicalException { return subscriptionRedisRepository.findByPlan(plan).stream().map(this::convert).collect(Collectors.toSet()); }
From source file:com.synopsys.integration.blackduck.service.model.ComponentVersionPolicyViolationCount.java
public ComponentVersionPolicyViolationCount(final NameValuePairView nameValuePair) { final Set<PolicySeverityType> policySeverityTypes = EnumSet.allOf(PolicySeverityType.class); final Set<String> policyStatusTypeValues = policySeverityTypes.stream().map(Object::toString) .collect(Collectors.toSet()); if (policyStatusTypeValues.contains(nameValuePair.getName())) { name = PolicySeverityType.valueOf(nameValuePair.getName()); }/*from ww w .j a v a 2s . c o m*/ if (nameValuePair.getValue() != null) { final String valueString = nameValuePair.getValue().toString(); if (NumberUtils.isCreatable(valueString)) { value = NumberUtils.createNumber(valueString).intValue(); } } }
From source file:com.wmfsystem.eurekaserver.broadcast.Server.java
public void run() { try {// w ww.java2 s. co m socket = new DatagramSocket(DEFAULT_PORT); } catch (Exception ex) { System.out.println("Problem creating socket on port: " + DEFAULT_PORT); } packet = new DatagramPacket(new byte[1], 1); while (true) { try { socket.receive(packet); System.out.println("Received from: " + packet.getAddress() + ":" + packet.getPort()); byte[] outBuffer = new java.util.Date().toString().getBytes(); packet.setData(outBuffer); packet.setLength(outBuffer.length); socket.setBroadcast(true); socket.send(packet); Set<InetAddress> localAddress = getLocalAddress(); Set<String> ips = localAddress.stream().map(ad -> ad.getHostAddress()).collect(Collectors.toSet()) .stream().sorted().collect(Collectors.toSet()); RestTemplate template = new RestTemplate(); ips.forEach(ip -> { template.exchange("http://" + packet.getAddress().getHostAddress().concat(":8000?ip={ip}"), HttpMethod.GET, HttpEntity.EMPTY, Void.class, ip.concat(":8000")); try { template.exchange("http://" + packet.getAddress().getHostAddress().concat(":8000?ip={ip}"), HttpMethod.GET, HttpEntity.EMPTY, Void.class, ip.concat(":8000")); } catch (Exception e) { e.printStackTrace(); } }); System.out.println("Message ----> " + packet.getAddress().getHostAddress()); } catch (IOException ie) { ie.printStackTrace(); } } }
From source file:com.juliuskrah.multipart.repository.AccountRepositoryTest.java
@Before public void before() { Account a = new Account(); a.setFirstName("Administrator"); a.setLastName("Administrator"); a.setUsername("admin"); a.setCreatedBy("system"); a.setAuthorities(Stream.of(new Authority("ROLE_USER")).collect(Collectors.toSet())); a.setPassword(encoder.encode("system")); accountRepository.save(a);/* w w w .j a va 2 s .com*/ }
From source file:io.gravitee.repository.redis.management.internal.impl.PlanRedisRepositoryImpl.java
@Override public Set<RedisPlan> findByApi(String api) { Set<Object> keys = redisTemplate.opsForSet().members(REDIS_KEY + ":api:" + api); List<Object> pageObjects = redisTemplate.opsForHash().multiGet(REDIS_KEY, keys); return pageObjects.stream().map(event -> convert(event, RedisPlan.class)).collect(Collectors.toSet()); }
From source file:io.gravitee.repository.redis.management.RedisApplicationRepository.java
@Override public Set<Application> findAll() throws TechnicalException { Set<RedisApplication> applications = applicationRedisRepository.findAll(); return applications.stream().map(this::convert).collect(Collectors.toSet()); }
From source file:com.vsct.dt.strowgr.admin.gui.mapping.json.EntryPointWithPortsMappingJson.java
@JsonCreator public EntryPointWithPortsMappingJson(@JsonProperty("haproxy") String haproxy, @JsonProperty("hapUser") String hapUser, @JsonProperty("haproxyVersion") String haproxyVersion, @JsonProperty("bindingId") int bindingId, @JsonProperty("syslogPort") Integer syslogPort, @JsonProperty("frontends") Set<EntryPointFrontendWithPortMappingJson> frontends, @JsonProperty("backends") Set<EntryPointBackendMappingJson> backends, @JsonProperty("context") Map<String, String> context) { super(haproxy, hapUser, haproxyVersion, bindingId, frontends.stream().map(identity()).collect(Collectors.toSet()), backends.stream().map(identity()).collect(Collectors.toSet()), context); this.syslogPort = syslogPort; }