List of usage examples for java.util.stream Collectors toCollection
public static <T, C extends Collection<T>> Collector<T, ?, C> toCollection(Supplier<C> collectionFactory)
From source file:com.mycompany.story.topic.application.TopicService.java
public TopicResult topic(TopicParameter parameter) { Title title = titleRepository.findOne(parameter.getTopicId()); List<Participant> participants = participantRepository.findByTopicId(parameter.getTopicId()); List<String> participantIds = participants.stream().map(Participant::getParticipantId) .collect(Collectors.toCollection(LinkedList::new)); List<Dialog> dialogs = dialogRepository.findByParticipantIdIn(participantIds); List<TopicResult.RoleResult> roleResults = participants.stream() .map(p -> new TopicResult.RoleResult(p.getParticipantId(), p.getNickname(), p.getIcon())) .collect(Collectors.toCollection(LinkedList::new)); List<TopicResult.DialogResult> dialogResults = dialogs.stream() .map(d -> new TopicResult.DialogResult(d.getParticipantId(), d.getContent(), d.getOrdinal())) .collect(Collectors.toCollection(LinkedList::new)); return new TopicResult(title.getTitle(), roleResults, dialogResults); }
From source file:ph.com.fsoft.temp.service.red.service.PersonColorServiceImpl.java
@Override public HashSet<PersonColorDto> findAll() { return StreamSupport.stream(personColorRepository.findAll().spliterator(), false).map(personColor -> { PersonDto personDto = personService.findById(personColor.getId()); return new PersonColorDto(personDto, personColor.getColor()); }).collect(Collectors.toCollection(HashSet::new)); }
From source file:com.mycompany.wolf.Game.java
public void rooms(Session session) { List roomInfos = rooms.values().stream() .map(room -> ImmutableMap.of("roomId", room.roomId, "count", room.count())) .collect(Collectors.toCollection(LinkedList::new)); Map<String, Object> resp = ImmutableMap.of("code", "listRoomsResp", "properties", roomInfos); String json = JsonUtils.toString(resp); session.getAsyncRemote().sendText(json); }
From source file:ph.com.fsoft.temp.service.blue.service.PersonServiceImpl.java
@Override public HashSet<PersonDto> findAll() { return StreamSupport .stream(personRepository.findAll().spliterator(), false).map(person -> new PersonDto(person.getId(), person.getFirstName(), person.getMiddleName(), person.getLastName())) .collect(Collectors.toCollection(HashSet::new)); }
From source file:net.jodah.failsafe.internal.actions.DoThrowAction.java
DoThrowAction(ActionRegistry<R>.Expectation expectation, String name, Throwable... throwables) { super(expectation, name); Validate.notNull(throwables, "invalid null throwables"); Validate.noNullElements(throwables, "invalid null throwable"); this.arguments = Arrays.asList(throwables); this.throwables = Stream.of(throwables).collect(Collectors.toCollection(LinkedList::new)); this.current = Collections.synchronizedList(new LinkedList<>(this.throwables)); }
From source file:com.yahoo.bullet.parsing.SpecificationTest.java
public static ArrayList<BulletRecord> makeList(int count) { return makeStream(count).collect(Collectors.toCollection(ArrayList::new)); }
From source file:com.github.horrorho.liquiddonkey.cloud.data.FileGroups.java
public static ChunkServer.FileGroups from(HttpClient client, Core core, String mmeAuthToken, Snapshot snapshot) throws BadDataException, IOException { logger.trace("<< get() < dsPrsID: {} udid: {} snapshot: {} files: {}", snapshot.dsPrsID(), snapshot.backupUDID(), snapshot.snapshotID(), snapshot.filesCount()); if (!core.dsPrsID().equals(snapshot.dsPrsID())) { logger.error("-- from() > dsPrsID mismatch, core: {} snapshot: {}", core.dsPrsID(), snapshot.dsPrsID()); }/*from w ww . j a va2 s. c om*/ // Signatures represent unique files hashes. // Discard duplicate signatures. Collisions unlikely. // Null signatures are empty files/ non-downloadables. Collection<ICloud.MBSFile> unique = snapshot.files().stream().filter(ICloud.MBSFile::hasSignature) .collect(Collectors.toCollection(HashSet::new)); logger.debug("-- get() > rationalized count: {}", unique.size()); List<ICloud.MBSFileAuthToken> authTokens = unique.isEmpty() ? new ArrayList<>() : fileGroupsClient.getFiles(client, snapshot.dsPrsID(), mmeAuthToken, core.mobileBackupUrl(), snapshot.backupUDID(), Integer.toString(snapshot.snapshotID()), unique); ICloud.MBSFileAuthTokens tokens = fileIdToSignatureAuthTokens(unique, authTokens); ChunkServer.FileGroups fileGroups = authTokens.isEmpty() ? ChunkServer.FileGroups.getDefaultInstance() : fileGroupsClient.authorizeGet(client, snapshot.dsPrsID(), core.contentUrl(), tokens); logger.trace(">> get() > fileGroups: {}", fileGroups.getFileGroupsCount()); return fileGroups; }
From source file:com.linecorp.armeria.server.docs.EndpointInfo.java
EndpointInfo(String hostnamePattern, String path, SerializationFormat defaultFormat, Set<SerializationFormat> availableFormats) { this.hostnamePattern = requireNonNull(hostnamePattern, "hostnamePattern"); this.path = requireNonNull(path, "path"); defaultMimeType = requireNonNull(defaultFormat, "defaultFormat").mimeType(); final Set<String> sortedAvailableMimeTypes = availableFormats.stream().map(SerializationFormat::mimeType) .collect(Collectors.toCollection(TreeSet::new)); availableMimeTypes = Collections.unmodifiableSet(sortedAvailableMimeTypes); }
From source file:org.datalorax.populace.core.walk.inspector.SetInspector.java
private static Iterator<RawElement> toRawElements(final Set<Object> set) { final ArrayList<RawElement> elements = set.stream().map(e -> new SetElement(e, set)) .collect(Collectors.toCollection(ArrayList::new)); return elements.iterator(); }
From source file:ph.com.fsoft.temp.service.red.service.PersonColorServiceImpl.java
@Override public HashSet<PersonColorDto> findByColor(String color) { return personColorRepository.findByColor(color).map(personColor -> { PersonDto personDto = personService.findById(personColor.getId()); return new PersonColorDto(personDto, personColor.getColor()); }).collect(Collectors.toCollection(HashSet::new)); }