Package com.speedment.jpastreamer.streamconfiguration


package com.speedment.jpastreamer.streamconfiguration
Provides interfaces for configuring custom Stream sources. StreamConfiguration instances are used to specify certain properties of a Stream. Instances of StreamConfiguration are guaranteed to be immutable and therefore inherently thread-safe.

API Usage

The following example demonstrates the usage of StreamConfiguration to configure a Stream for querying films, joining with related entities, and applying filtering operations:

 JPAStreamer jpaStreamer = JPAStreamer.of("sakila"); 
 
 jpaStreamer.stream(
     StreamConfiguration.of(Film.class)
         .joining(Film$.actors))
 )
      .filter(Film$.length.between(100, 120))
      .forEach(System.out::println);
 

In this example a StreamConfiguration is created using the static of method, specifying the entity class (`Film` in this case). The joining-method is then used to define the entities to join with (in this case, `actors` and `language`). The resulting StreamConfiguration instance is then used to create a stream using the JPAStreamer.stream() method. A filtering operation is applied on the stream to include films with a length between 100 and 120 and the results are printed.

This following example demonstrates the usage of StreamConfiguration to configure a stream for querying films and applying sorting and limiting operations:


 JPAStreamer jpaStreamer = JPAStreamer.of("sakila");

 jpaStreamer.stream(
          StreamConfiguration.of(Film.class)
              .selecting(Projection.select(Film$.filmId, Film$.title)
 )
     .sorted(Film$.length.reversed())
     .limit(3)
     .forEach(System.out::println);
 

In the example above, a StreamConfiguration is created using the static of method, specifying the entity class (Film in this case). The selecting method is then used to define the projections (selected properties) for the query. The resulting StreamConfiguration instance is then used to create a stream using the JPAStreamer.stream() method. Sorting and limiting operations are applied on the stream before printing the results.

Note that StreamConfiguration instances are immutable, meaning that any modification operations will return a new instance, ensuring thread-safety and preventing unintended side effects.