Example usage for java.util.stream Stream concat

List of usage examples for java.util.stream Stream concat

Introduction

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

Prototype

public static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b) 

Source Link

Document

Creates a lazily concatenated stream whose elements are all the elements of the first stream followed by all the elements of the second stream.

Usage

From source file:org.lightjason.agentspeak.language.instantiable.plan.CPlan.java

@Override
@SuppressWarnings("unchecked")
public final double score(final IAgent<?> p_agent) {
    return p_agent.aggregation()
            .evaluate(Stream.concat(Stream.of(super.score(p_agent)),
                    Stream.of(m_annotation.containsKey(IAnnotation.EType.SCORE)
                            ? ((Number) m_annotation.get(IAnnotation.EType.SCORE).value()).doubleValue()
                            : 0)));/*  w  w  w . j a v  a  2  s.  c  o  m*/
}

From source file:com.github.mrenou.jacksonatic.internal.introspection.AnnotatedClassConstructor.java

@SuppressWarnings("unchecked")
private Optional<ClassMappingInternal<Object>> getClassMappingFromSuperTypes(Class<?> type,
        ClassesMapping serOrDeserClassesMapping, ClassesMapping mergedClassesMapping) {
    List<Class<?>> superTypes = ClassUtil.findSuperTypes(type, Object.class);
    Collections.reverse(superTypes);
    return Stream.concat(Stream.of(Object.class), superTypes.stream())
            .map(superType -> (Class<Object>) superType)
            .map(superType -> Optional.ofNullable(mergedClassesMapping.getOpt(superType)
                    .orElseGet(() -> mergeAndPutInMergedClassesMapping(mergedClassesMapping, superType,
                            serOrDeserClassesMapping.getOpt(superType),
                            classesMappingByOperation.get(ANY).getOpt(superType)))))
            .reduce(Optional.empty(), Mergeable::merge);
}

From source file:org.openepics.discs.conf.webservice.InstallationSlotResourceImpl.java

private List<PropertyValue> getPropertyValues(final Slot slot) {
    final InstallationRecord record = installationEJB.getActiveInstallationRecordForSlot(slot);

    final Stream<? extends PropertyValue> externalProps = Stream.concat(
            slot.getComponentType().getComptypePropertyList().stream()
                    .filter(propValue -> !propValue.isPropertyDefinition())
                    .map(propValue -> createPropertyValue(propValue)),
            record == null ? Stream.empty()
                    : record.getDevice().getDevicePropertyList().stream()
                            .map(propValue -> createPropertyValue(propValue)));

    return Stream.concat(slot.getSlotPropertyList().stream().map(propValue -> createPropertyValue(propValue)),
            externalProps).collect(Collectors.toList());
}

From source file:com.jslsolucoes.tagria.lib.compressor.Compressor.java

public void compressCss() throws IOException {

    File root = new File(new File(source, "css"), THEME);

    for (String theme : themes) {

        String[] files = new String[] { "tagria.bootstrap.css", "tagria.bootstrap.extension.css",
                "tagria.common.css", "tagria.font.awesome.css", "tagria.fullcalendar.css",
                "tagria.jquery.ui.css", "tagria.jquery.ui.theme.css", "tagria.jquery.ui.treeview.css",
                "tagria.jquery.ui.timepicker.css", "tagria.jquery.ui.wave.css", "tagria.jquery.ui.loading.css",
                "tagria.jquery.ui.card.css", "tagria.jquery.syntax.highlight.css" };

        String content = StringUtils.join(Stream
                .concat(Arrays.asList(files).stream().map(file -> new File(new File(root, "base"), file)),
                        Arrays.asList(new File(root, theme).listFiles()).stream())
                .map(file -> normalizeCssFile(file, theme)).collect(Collectors.toList()), "\n");

        FileUtils.writeStringToFile(/*  w  ww .  j a v  a  2  s.c  o  m*/
                new File(new File(new File(new File(destination, "css"), THEME), theme), "tagria-ui.css"),
                compress ? minifyCss(content) : content, CHARSET);
        logger.info("CSS THEME %s COMPRESSED", theme);
    }
}

From source file:org.mitre.mpf.wfm.service.component.StartupComponentRegistrationServiceImpl.java

private List<Path> getComponentRegistrationOrder(Collection<RegisterComponentModel> allComponents,
        Collection<Path> uploadedComponentPackages, Map<Path, Path> packageToDescriptorMapping) {

    Stream<Path> registeredDescriptors = allComponents.stream()
            .filter(rcm -> rcm.getComponentState() == ComponentState.REGISTERED)
            .map(rcm -> Paths.get(rcm.getJsonDescriptorPath()));

    Set<Path> unregisteredPaths = uploadedComponentPackages.stream()
            .map(p -> packageToDescriptorMapping.getOrDefault(p, p)).collect(toSet());

    Set<Path> allPaths = Stream.concat(registeredDescriptors, unregisteredPaths.stream()).collect(toSet());

    try {//from   w  w w .  ja  v  a 2 s .com
        return _componentDependencyFinder.getRegistrationOrder(allPaths).stream()
                .filter(unregisteredPaths::contains).collect(toList());
    } catch (IllegalStateException e) {
        _log.error("An error occurred while trying to get component registration order.", e);
        for (Path componentPath : uploadedComponentPackages) {
            Path descriptorPath = packageToDescriptorMapping.get(componentPath);
            if (descriptorPath == null) {
                _componentStateSvc.addRegistrationErrorEntry(componentPath);
            } else {
                _componentStateSvc.addEntryForDeployedPackage(componentPath, descriptorPath);
            }
        }
        return Collections.emptyList();
    }
}

From source file:com.github.robozonky.app.events.SessionEvents.java

@SuppressWarnings({ "rawtypes", "unchecked" })
Runnable fireAny(final LazyEvent<? extends Event> event) {
    // loan all listeners
    debugListeners.forEach(l -> l.requested(event));
    final Class<? extends Event> eventType = event.getEventType();
    final List<EventListenerSupplier<? extends Event>> s = suppliers.computeIfAbsent(eventType,
            SessionEvents::retrieveListenerSuppliers);
    // send the event to all listeners, execute on the background
    final Stream<EventListener> registered = s.stream().map(Supplier::get)
            .flatMap(l -> l.stream().flatMap(Stream::of));
    final Stream<EventListener> withInjected = injectedDebugListener == null ? registered
            : Stream.concat(Stream.of(injectedDebugListener), registered);
    return runAsync(withInjected.map(l -> new EventTriggerRunnable(event, l)));
}

From source file:com.github.mrenou.jacksonatic.internal.annotations.ClassAnnotationDecorator.java

private void addConstructorAnnotations(AnnotatedClass annotatedClass, ClassBuilderMapping classBuilderMapping) {
    AnnotatedConstructor constructorMember = Stream
            .concat(annotatedClass.getConstructors().stream(),
                    Optional.ofNullable(annotatedClass.getDefaultConstructor()).map(Stream::of)
                            .orElse(Stream.empty()))
            .filter(constructor -> constructor.getMember().equals(classBuilderMapping.getConstructor()))
            .findFirst().get();/*from  ww  w  .  j  a  v  a  2s.  c  o  m*/
    setAnnotationsOnMemberWithParams(classBuilderMapping.getAnnotations(),
            classBuilderMapping.getParametersMapping(), constructorMember);
}

From source file:org.springframework.cloud.deployer.spi.cloudfoundry.CloudFoundry2630AndLaterTaskLauncher.java

private String getCommand(SummaryApplicationResponse application, AppDeploymentRequest request) {
    return Stream.concat(Stream.of(application.getDetectedStartCommand()),
            request.getCommandlineArguments().stream()).collect(Collectors.joining(" "));
}

From source file:com.wormsim.animals.AnimalStage2.java

@Override
public String toRecentMeanString() {
    return Stream
            .concat(Stream.concat(Stream.concat(Stream.of(food_rate), Stream.of(pheromone_rates)),
                    Stream.of(dev_time)), Stream.of(development))
            .filter((v) -> v.isVisiblyTracked()).map((v) -> v.toRecentMeanString()).collect(Utils.TAB_JOINING);
}

From source file:org.onosproject.store.primitives.impl.DefaultTransactionalMap.java

protected Stream<MapUpdate<K, V>> updatesStream() {
    return Stream.concat(
            // 1st stream: delete ops
            deleteSet.stream().map(key -> Pair.of(key, readCache.get(key))).filter(e -> e.getValue() != null)
                    .map(e -> MapUpdate.<K, V>newBuilder().withMapName(name)
                            .withType(MapUpdate.Type.REMOVE_IF_VERSION_MATCH).withKey(e.getKey())
                            .withCurrentVersion(e.getValue().version()).build()),
            // 2nd stream: write ops
            writeCache.entrySet().stream().map(e -> {
                Versioned<V> original = readCache.get(e.getKey());
                if (original == null) {
                    return MapUpdate.<K, V>newBuilder().withMapName(name).withType(MapUpdate.Type.PUT_IF_ABSENT)
                            .withKey(e.getKey()).withValue(e.getValue()).build();
                } else {
                    return MapUpdate.<K, V>newBuilder().withMapName(name)
                            .withType(MapUpdate.Type.PUT_IF_VERSION_MATCH).withKey(e.getKey())
                            .withCurrentVersion(original.version()).withValue(e.getValue()).build();
                }//from ww  w  .j a va2s  .c  o  m
            }));
}