Example usage for java.util.stream StreamSupport stream

List of usage examples for java.util.stream StreamSupport stream

Introduction

In this page you can find the example usage for java.util.stream StreamSupport stream.

Prototype

public static <T> Stream<T> stream(Spliterator<T> spliterator, boolean parallel) 

Source Link

Document

Creates a new sequential or parallel Stream from a Spliterator .

Usage

From source file:de.msg.repository.RouteRepositoryImpl.java

@Override
public Iterable<Route> findByDeparture(String departure) {
    return StreamSupport.stream(driver.getRouteList().spliterator(), false).filter(new Predicate<Route>() {
        @Override//w ww .j av a2  s .  c om
        public boolean test(Route route) {
            return route.getDeparture().equals(departure);
        }
    }).collect(Collectors.toList());
}

From source file:com.davidmogar.alsa.services.bus.internal.BusManagerServiceImpl.java

@Override
public List<BusDto> findAll() {
    return StreamSupport.stream(busDataService.findAll().spliterator(), false).map(BusDto::new)
            .collect(Collectors.toList());
}

From source file:net.hamnaberg.json.Query.java

public static Query create(Target target, String rel, Optional<String> prompt, Optional<String> name,
        Iterable<Property> data) {
    ObjectNode obj = JsonNodeFactory.instance.objectNode();
    obj.put("href", target.toString());
    if (target.isURITemplate()) {
        obj.put("encoding", "uri-template");
    }//w ww.ja v a  2 s.  c o  m
    obj.put("rel", rel);
    prompt.ifPresent(value -> obj.put("prompt", value));
    name.ifPresent(value -> obj.put("name", value));
    if (!Iterables.isEmpty(data)) {
        obj.set("data", StreamSupport.stream(data.spliterator(), false).map(Extended::asJson)
                .collect(JsonNodeFactory.instance::arrayNode, ArrayNode::add, ArrayNode::addAll));
    }
    return new Query(obj);
}

From source file:nu.yona.server.entities.ActivityRepositoryMock.java

@Override
public Set<Activity> findByDeviceAnonymized(DeviceAnonymized deviceAnonymized) {
    return StreamSupport.stream(findAll().spliterator(), false).filter(
            a -> a.getDeviceAnonymized().map(DeviceAnonymized::getId).orElse(null) == deviceAnonymized.getId())
            .collect(Collectors.toSet());
}

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:org.cryptomator.frontend.webdav.mount.WindowsDriveLetters.java

public Set<Character> getOccupiedDriveLetters() {
    if (!SystemUtils.IS_OS_WINDOWS) {
        throw new UnsupportedOperationException("This method is only defined for Windows file systems");
    }//from  w  ww  .  j a  va2 s .co m
    Iterable<Path> rootDirs = FileSystems.getDefault().getRootDirectories();
    return StreamSupport.stream(rootDirs.spliterator(), false).map(Path::toString).map(CharUtils::toChar)
            .map(Character::toUpperCase).collect(toSet());
}

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:com.avanza.ymer.MongoDocumentCollection.java

@Override
public Stream<DBObject> findAll(SpaceObjectFilter<?> objectFilter) {
    if (MongoPartitionFilter.canCreateFrom(objectFilter)) {
        MongoPartitionFilter mongoPartitionFilter = MongoPartitionFilter.create(objectFilter);
        return StreamSupport.stream(dbCollection.find(mongoPartitionFilter.toDBObject()).spliterator(), false);
    }/* ww w  . j a  va 2  s.c  o  m*/
    return findAll();
}

From source file:nu.yona.server.subscriptions.service.WhiteListedNumberService.java

@Transactional
public Set<String> getAllWhiteListedNumbers() {
    return StreamSupport.stream(WhiteListedNumber.getRepository().findAll().spliterator(), false)
            .map(WhiteListedNumber::getMobileNumber).collect(Collectors.toSet());
}

From source file:com.wrmsr.kleist.util.Itertools.java

public static <L, R> Stream<Pair<L, R>> zip(Stream<L> left, Stream<R> right) {
    return StreamSupport.stream(zip(left.spliterator(), right.spliterator()), false);
}