Java 11 migrate all remaining s (#1120)
* Moves saga to Java 11 * Moves semaphore to Java 11 * Moves servant to Java 11 * Moves serverless to Java 11 * Moves service-layer to Java 11 * Moves service-locator to Java 11 * Moves sharding to Java 11 * Moves singleton to Java 11 * Moves spatial-partition to Java 11 * Moves specification to Java 11 * Moves state to Java 11 * Moves step-builder to Java 11 * Moves strategy to Java 11 * Moves subclass-sandbox to Java 11 * Fixes checkstyle issues
This commit is contained in:
committed by
Ilkka Seppälä
parent
310ae50248
commit
cd2a2e7711
@@ -100,24 +100,24 @@ public class MassGreaterThanSelector extends AbstractSelector<Creature> {
|
||||
With these building blocks in place, we can perform a search for red creatures as follows:
|
||||
|
||||
```java
|
||||
List<Creature> redCreatures = creatures.stream().filter(new ColorSelector(Color.RED))
|
||||
var redCreatures = creatures.stream().filter(new ColorSelector(Color.RED))
|
||||
.collect(Collectors.toList());
|
||||
```
|
||||
|
||||
But we could also use our parameterized selector like this:
|
||||
|
||||
```java
|
||||
List<Creature> heavyCreatures = creatures.stream().filter(new MassGreaterThanSelector(500.0)
|
||||
var heavyCreatures = creatures.stream().filter(new MassGreaterThanSelector(500.0)
|
||||
.collect(Collectors.toList());
|
||||
```
|
||||
|
||||
Our third option is to combine multiple selectors together. Performing a search for special creatures (defined as red, flying, and not small) could be done as follows:
|
||||
|
||||
```java
|
||||
AbstractSelector specialCreaturesSelector =
|
||||
var specialCreaturesSelector =
|
||||
new ColorSelector(Color.RED).and(new MovementSelector(Movement.FLYING)).and(new SizeSelector(Size.SMALL).not());
|
||||
|
||||
List<Creature> specialCreatures = creatures.stream().filter(specialCreaturesSelector)
|
||||
var specialCreatures = creatures.stream().filter(specialCreaturesSelector)
|
||||
.collect(Collectors.toList());
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user