Example usage for java.util List stream

List of usage examples for java.util List stream

Introduction

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

Prototype

default Stream<E> stream() 

Source Link

Document

Returns a sequential Stream with this collection as its source.

Usage

From source file:com.qpark.maven.plugin.flowmapper.AbstractGenerator.java

public static final boolean isListImport(
        final List<Entry<ComplexTypeChild, List<ComplexTypeChild>>> childrenTree) {
    final boolean value = childrenTree.stream()
            .filter(child -> child.getKey().isList() || isChildListImport(child.getValue())).findFirst()
            .isPresent();/* ww  w . j a v  a 2 s . co m*/
    return value;
}

From source file:com.ethercamp.harmony.desktop.DesktopUtil.java

/**
 * Find initial exception by visiting/*from  w  w  w  . j  a  v  a  2  s . co m*/
 */
public static Throwable findCauseFromSpringException(Throwable e) {
    final List<Class<? extends Exception>> skipList = Arrays.asList(BeansException.class,
            EmbeddedServletContainerException.class, ApplicationContextException.class);

    for (int i = 0; i < 50; i++) {
        final Throwable inner = e;
        final boolean isSkipped = skipList.stream().anyMatch(c -> c.isAssignableFrom(inner.getClass()));
        if (isSkipped) {
            e = e.getCause();
        } else {
            return e;
        }
    }
    return e;
}

From source file:info.archinnov.achilles.internals.parser.validator.BeanValidator.java

public static void validateNoDuplicateNames(AptUtils aptUtils, TypeName rawClassType,
        List<TypeParsingResult> parsingResults) {
    Map<String, String> mapping = new HashMap<>();
    parsingResults.stream().map(x -> x.context).forEach(context -> {
        final String fieldName = context.fieldName;
        final String cqlColumn = context.cqlColumn;
        if (mapping.containsKey(fieldName)) {
            aptUtils.printError("The class '%s' already contains a field with name '%s'", rawClassType,
                    fieldName);/*from w  ww  . ja va  2s  .c  o  m*/
        } else if (mapping.containsValue(cqlColumn)) {
            aptUtils.printError("The class '%s' already contains a cql column with name '%s'", rawClassType,
                    cqlColumn);
        } else {
            mapping.put(fieldName, cqlColumn);
        }
    });
}

From source file:com.robertsmieja.test.utils.junit.GettersAndSettersUtils.java

static List<Field> getFields(Class<?> aClass, Predicate<Field> fieldPredicate) {
    List<Field> allFields = FieldUtils.getAllFieldsList(aClass);
    List<Field> excludedFields = FieldUtils.getFieldsListWithAnnotation(aClass, IgnoreForTests.class);
    return allFields.stream().filter(field -> !field.isSynthetic())
            .filter(field -> !excludedFields.contains(field)).filter(field -> !isFinal(field.getModifiers()))
            .filter(fieldPredicate).collect(Collectors.toList());
}

From source file:com.evolveum.midpoint.model.api.util.EvaluatedPolicyRuleUtil.java

public static List<TreeNode<EvaluatedPolicyRuleTriggerType>> arrangeForPresentationExt(
        List<EvaluatedPolicyRuleTriggerType> triggers) {
    // augment/*from w w w  . j a va  2  s  .co m*/
    List<AugmentedTrigger<AdditionalData>> augmentedTriggers = triggers.stream()
            .map(t -> new AugmentedTrigger<>(t, null)).collect(Collectors.toList());
    List<TreeNode<AugmentedTrigger<AdditionalData>>> trees = arrangeForPresentationExt(augmentedTriggers, null);
    // de-augment
    return trees.stream().map(tree -> tree.tranform(at -> at.trigger)).collect(Collectors.toList());
}

From source file:com.intellij.lang.jsgraphql.endpoint.doc.psi.JSGraphQLEndpointDocPsiUtil.java

/**
 * Gets the text of the continuous comments placed directly above the specified element
 * @param element element whose previous siblings are enumerated and included if they're documentation comments
 * @return the combined text of the documentation comments, preserving line breaks, or <code>null</code> if no documentation is available
 *//*  www . ja v a2 s  .  com*/
public static String getDocumentation(PsiElement element) {
    final PsiComment comment = PsiTreeUtil.getPrevSiblingOfType(element, PsiComment.class);
    if (isDocumentationComment(comment)) {
        final List<PsiComment> siblings = Lists.newArrayList(comment);
        getDocumentationCommentSiblings(comment, siblings, PsiElement::getPrevSibling);
        Collections.reverse(siblings);
        return siblings.stream().map(c -> StringUtils.stripStart(c.getText(), "# "))
                .collect(Collectors.joining("\n"));
    }
    return null;
}

From source file:com.uber.hoodie.common.util.CompactionUtils.java

/**
 * Get all pending compaction plans along with their instants
 *
 * @param metaClient Hoodie Meta Client// ww  w  . ja  v a  2  s.c  o  m
 */
public static List<Pair<HoodieInstant, HoodieCompactionPlan>> getAllPendingCompactionPlans(
        HoodieTableMetaClient metaClient) {
    List<HoodieInstant> pendingCompactionInstants = metaClient.getActiveTimeline()
            .filterPendingCompactionTimeline().getInstants().collect(Collectors.toList());
    return pendingCompactionInstants.stream().map(instant -> {
        try {
            HoodieCompactionPlan compactionPlan = AvroUtils
                    .deserializeCompactionPlan(metaClient.getActiveTimeline()
                            .getInstantAuxiliaryDetails(
                                    HoodieTimeline.getCompactionRequestedInstant(instant.getTimestamp()))
                            .get());
            return Pair.of(instant, compactionPlan);
        } catch (IOException e) {
            throw new HoodieException(e);
        }
    }).collect(Collectors.toList());
}

From source file:ConcurrentTest.java

@BeforeClass
public static void setUpClass() throws IOException {

    List<HashResultHolder> list = new ObjectMapper().readValue(
            JacksonJacksumTest.class.getResourceAsStream("/jacksum_image.json"),
            new TypeReference<List<HashResultHolder>>() {
            });/*from w ww  .  ja  v  a 2 s  .c  o m*/

    IMAGE_FILE_RESULTS = list.stream()
            .collect(Collectors.toMap(HashResultHolder::getAlgorithm, Function.identity()));

}

From source file:alfio.util.Validator.java

private static boolean validateDescriptionList(List<EventModification.AdditionalServiceText> descriptions) {
    return descriptions.stream().allMatch(t -> StringUtils.isNotBlank(t.getValue()));
}

From source file:ee.ria.xroad.common.conf.globalconf.SharedParameters.java

private static List<X509Certificate> getTopOrIntermediateCaCerts(List<CaInfoType> typesUnderCA) {
    return typesUnderCA.stream().map(c -> readCertificate(c.getCert())).collect(Collectors.toList());
}