Tabnine Logo
StreamUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
StreamUtils
in
org.springframework.data.util

Best Java code snippets using org.springframework.data.util.StreamUtils (Showing top 20 results out of 315)

Refine searchRefine arrow

  • Stream
origin: spring-projects/spring-data-mongodb

public static List<Object> toIds(Collection<Document> documents) {
  return documents.stream()//
      .map(it -> it.get(ID_FIELD))//
      .collect(StreamUtils.toUnmodifiableList());
}
origin: spring-projects/spring-data-mongodb

@Override
public Stream<T> stream() {
  return StreamUtils.createStreamFromIterator(doStream());
}
origin: spring-projects/spring-data-jpa

/**
 * Creates a new {@link JpaMetamodel} for the given JPA {@link Metamodel}.
 *
 * @param metamodel must not be {@literal null}.
 */
private JpaMetamodel(Metamodel metamodel) {
  Assert.notNull(metamodel, "Metamodel must not be null!");
  this.metamodel = metamodel;
  this.managedTypes = Lazy.of(() -> metamodel.getManagedTypes().stream() //
      .map(ManagedType::getJavaType) //
      .filter(it -> it != null) //
      .collect(StreamUtils.toUnmodifiableSet()));
}
origin: spring-projects/spring-data-mongodb

@Override
public <S extends T> List<S> insert(Iterable<S> entities) {
  Assert.notNull(entities, "The given Iterable of entities not be null!");
  List<S> list = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList());
  if (list.isEmpty()) {
    return list;
  }
  return new ArrayList<>(mongoOperations.insertAll(list));
}
origin: spring-projects/spring-data-envers

@SuppressWarnings("unchecked")
private List<Revision<N, T>> toRevisions(Map<N, T> source, Map<Number, Object> revisionEntities) {
  return source.entrySet().stream() //
      .map(entry -> Revision.of( //
          (RevisionMetadata<N>) getRevisionMetadata(revisionEntities.get(entry.getKey())), //
          entry.getValue())) //
      .sorted() //
      .collect(StreamUtils.toUnmodifiableList());
}
origin: apache/servicemix-bundles

  @Override
  @SuppressWarnings("null")
  public int compare(PersistentPropertyPath<?> left, PersistentPropertyPath<?> right) {
    Function<PersistentProperty<?>, Integer> mapper = it -> it.getName().length();
    Stream<Integer> leftNames = left.stream().map(mapper);
    Stream<Integer> rightNames = right.stream().map(mapper);
    return StreamUtils.zip(leftNames, rightNames, (l, r) -> l - r) //
        .filter(it -> it != 0) //
        .findFirst() //
        .orElse(0);
  }
}
origin: spring-projects/spring-data-jpa

  /**
   * Obtains all {@link Metamodel} instances of the current {@link ApplicationContext}.
   *
   * @return
   */
  private Set<Metamodel> getMetamodels() {

    if (beanFactory == null) {
      throw new IllegalStateException("BeanFactory must not be null!");
    }

    Collection<EntityManagerFactory> factories = BeanFactoryUtils
        .beansOfTypeIncludingAncestors(beanFactory, EntityManagerFactory.class).values();

    return factories.stream() //
        .map(EntityManagerFactory::getMetamodel) //
        .collect(StreamUtils.toUnmodifiableSet());
  }
}
origin: org.springframework.data/spring-data-gemfire

@Override
public Collection<T> findAllById(Iterable<ID> ids) {
  List<ID> keys = Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList());
  return CollectionUtils.<ID, T>nullSafeMap(this.template.getAll(keys)).values().stream()
    .filter(Objects::nonNull).collect(Collectors.toList());
}
origin: org.springframework.cloud/spring-cloud-gcp-data-spanner

/**
 * Only provides types that are also annotated with {@link Table}.
 */
@Override
public Iterable<? extends TypeInformation<?>> getPersistentEntityTypes() {
  return StreamUtils
      .createStreamFromIterator(super.getPersistentEntityTypes().iterator())
      .filter((typeInfo) -> typeInfo.getType().isAnnotationPresent(Table.class))
      .collect(Collectors.toList());
}
origin: apache/servicemix-bundles

  @Override
  public Set<MethodMetadata> getMethods(String name) {
    Assert.hasText(name, "Method name must not be null or empty");
    return methodMetadataSet.stream() //
        .filter(it -> it.getMethodName().equals(name)) //
        .collect(StreamUtils.toUnmodifiableSet());
  }
}
origin: apache/servicemix-bundles

/**
 * Creates a new {@link Revisions} instance using the given revisions.
 *
 * @param revisions must not be {@literal null}.
 * @param latestLast
 */
private Revisions(List<? extends Revision<N, T>> revisions, boolean latestLast) {
  Assert.notNull(revisions, "Revisions must not be null!");
  this.revisions = revisions.stream()//
      .sorted(latestLast ? NATURAL_ORDER : NATURAL_ORDER.reversed())//
      .collect(StreamUtils.toUnmodifiableList());
  this.latestLast = latestLast;
}
origin: apache/servicemix-bundles

/**
 * Returns {@link PropertyDescriptor}s for all properties exposed by the given type and all its super interfaces.
 *
 * @return
 */
List<PropertyDescriptor> getDescriptors() {
  return collectDescriptors().distinct().collect(StreamUtils.toUnmodifiableList());
}
origin: spring-projects/spring-data-rest

/**
 * Returns an unmodifiable {@link Set} of all underlying {@link HttpMethod}s.
 * 
 * @return
 */
default Set<HttpMethod> toSet() {
  return stream().collect(StreamUtils.toUnmodifiableSet());
}
origin: apache/servicemix-bundles

private MultiValueMap<NameAndArgumentCount, Function> getFunctions(Object target) {
  return methods.stream().collect(toMultiMap(NameAndArgumentCount::of, m -> new Function(m, target)));
}
origin: spring-projects/spring-data-jdbc

private Stream<String> getColumnNameStream(String prefix) {
  return StreamUtils.createStreamFromIterator(entity.iterator()) //
      .flatMap(p -> getColumnNameStream(p, prefix));
}
origin: apache/servicemix-bundles

/**
 * Returns a {@link Stream} backed by the given {@link CloseableIterator} and forwarding calls to
 * {@link Stream#close()} to the iterator.
 *
 * @param iterator must not be {@literal null}.
 * @return
 * @since 2.0
 */
public static <T> Stream<T> createStreamFromIterator(CloseableIterator<T> iterator) {
  Assert.notNull(iterator, "Iterator must not be null!");
  return createStreamFromIterator((Iterator<T>) iterator).onClose(() -> iterator.close());
}
origin: spring-projects/spring-data-mongodb

@Override
public <S extends T> Flux<S> insert(Iterable<S> entities) {
  Assert.notNull(entities, "The given Iterable of entities must not be null!");
  List<S> source = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList());
  return source.isEmpty() ? Flux.empty() : Flux.from(mongoOperations.insertAll(source));
}
origin: org.springframework.data/spring-data-jpa

  /**
   * Obtains all {@link Metamodel} instances of the current {@link ApplicationContext}.
   *
   * @return
   */
  private Set<Metamodel> getMetamodels() {

    if (beanFactory == null) {
      throw new IllegalStateException("BeanFactory must not be null!");
    }

    Collection<EntityManagerFactory> factories = BeanFactoryUtils
        .beansOfTypeIncludingAncestors(beanFactory, EntityManagerFactory.class).values();

    return factories.stream() //
        .map(EntityManagerFactory::getMetamodel) //
        .collect(StreamUtils.toUnmodifiableSet());
  }
}
origin: org.springframework.data/spring-data-geode

@Override
public Collection<T> findAllById(Iterable<ID> ids) {
  List<ID> keys = Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList());
  return CollectionUtils.<ID, T>nullSafeMap(this.template.getAll(keys)).values().stream()
    .filter(Objects::nonNull).collect(Collectors.toList());
}
origin: spring-cloud/spring-cloud-gcp

/**
 * Only provides types that are also annotated with {@link Table}.
 */
@Override
public Iterable<? extends TypeInformation<?>> getPersistentEntityTypes() {
  return StreamUtils
      .createStreamFromIterator(super.getPersistentEntityTypes().iterator())
      .filter((typeInfo) -> typeInfo.getType().isAnnotationPresent(Table.class))
      .collect(Collectors.toList());
}
org.springframework.data.utilStreamUtils

Javadoc

Spring Data specific Java Stream utility methods and classes.

Most used methods

  • toUnmodifiableList
  • createStreamFromIterator
  • toUnmodifiableSet
  • toMultiMap
    Returns a Collector to create a MultiValueMap.
  • zip
    Zips the given Streams using the given BiFunction. The resulting Stream will have the length of the

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • scheduleAtFixedRate (Timer)
  • getContentResolver (Context)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now