@Test public void test() { String[] args = {}; App.main(args); }
public static void main(String[] args) { List<Creature> creatures = Arrays.asList(new Goblin(), new Octopus(), new Dragon(), new Shark(), new Troll(), new KillerBee()); LOGGER.info("Find all walking creatures"); List<Creature> walkingCreatures = creatures.stream().filter(new MovementSelector(Movement.WALKING)) .collect(Collectors.toList()); walkingCreatures.stream().forEach(c -> LOGGER.info(c.toString())); LOGGER.info("Find all dark creatures"); List<Creature> darkCreatures = creatures.stream().filter(new ColorSelector(Color.DARK)).collect(Collectors.toList()); darkCreatures.stream().forEach(c -> LOGGER.info(c.toString())); LOGGER.info("Find all red and flying creatures"); List<Creature> redAndFlyingCreatures = creatures.stream() .filter(new ColorSelector(Color.RED).and(new MovementSelector(Movement.FLYING))) .collect(Collectors.toList()); redAndFlyingCreatures.stream().forEach(c -> LOGGER.info(c.toString())); }
App { public static void main(String[] args) { List<Creature> creatures = Arrays.asList(new Goblin(), new Octopus(), new Dragon(), new Shark(), new Troll(), new KillerBee()); LOGGER.info("Find all walking creatures"); List<Creature> walkingCreatures = creatures.stream().filter(new MovementSelector(Movement.WALKING)) .collect(Collectors.toList()); walkingCreatures.stream().forEach(c -> LOGGER.info(c.toString())); LOGGER.info("Find all dark creatures"); List<Creature> darkCreatures = creatures.stream().filter(new ColorSelector(Color.DARK)).collect(Collectors.toList()); darkCreatures.stream().forEach(c -> LOGGER.info(c.toString())); LOGGER.info("Find all red and flying creatures"); List<Creature> redAndFlyingCreatures = creatures.stream() .filter(new ColorSelector(Color.RED).and(new MovementSelector(Movement.FLYING))) .collect(Collectors.toList()); redAndFlyingCreatures.stream().forEach(c -> LOGGER.info(c.toString())); } }
App { public static void main(String[] args) { List<Creature> creatures = Arrays.asList(new Goblin(), new Octopus(), new Dragon(), new Shark(), new Troll(), new KillerBee()); LOGGER.info("Find all walking creatures"); List<Creature> walkingCreatures = creatures.stream().filter(new MovementSelector(Movement.WALKING)) .collect(Collectors.toList()); walkingCreatures.stream().forEach(c -> LOGGER.info(c.toString())); LOGGER.info("Find all dark creatures"); List<Creature> darkCreatures = creatures.stream().filter(new ColorSelector(Color.DARK)).collect(Collectors.toList()); darkCreatures.stream().forEach(c -> LOGGER.info(c.toString())); LOGGER.info("Find all red and flying creatures"); List<Creature> redAndFlyingCreatures = creatures.stream() .filter(new ColorSelector(Color.RED).and(new MovementSelector(Movement.FLYING))) .collect(Collectors.toList()); redAndFlyingCreatures.stream().forEach(c -> LOGGER.info(c.toString())); }  }
App { public static void main(String[] args) { List<Creature> creatures = Arrays.asList(new Goblin(), new Octopus(), new Dragon(), new Shark(), new Troll(), new KillerBee()); LOGGER.info("Find all walking creatures"); List<Creature> walkingCreatures = creatures.stream().filter(new MovementSelector(Movement.WALKING)) .collect(Collectors.toList()); walkingCreatures.stream().forEach(c -> LOGGER.info(c.toString())); LOGGER.info("Find all dark creatures"); List<Creature> darkCreatures = creatures.stream().filter(new ColorSelector(Color.DARK)).collect(Collectors.toList()); darkCreatures.stream().forEach(c -> LOGGER.info(c.toString())); LOGGER.info("Find all red and flying creatures"); List<Creature> redAndFlyingCreatures = creatures.stream() .filter(new ColorSelector(Color.RED).and(new MovementSelector(Movement.FLYING))) .collect(Collectors.toList()); redAndFlyingCreatures.stream().forEach(c -> LOGGER.info(c.toString())); }  static void main(String[] args); }
App { public static void main(String[] args) { List<Creature> creatures = Arrays.asList(new Goblin(), new Octopus(), new Dragon(), new Shark(), new Troll(), new KillerBee()); LOGGER.info("Find all walking creatures"); List<Creature> walkingCreatures = creatures.stream().filter(new MovementSelector(Movement.WALKING)) .collect(Collectors.toList()); walkingCreatures.stream().forEach(c -> LOGGER.info(c.toString())); LOGGER.info("Find all dark creatures"); List<Creature> darkCreatures = creatures.stream().filter(new ColorSelector(Color.DARK)).collect(Collectors.toList()); darkCreatures.stream().forEach(c -> LOGGER.info(c.toString())); LOGGER.info("Find all red and flying creatures"); List<Creature> redAndFlyingCreatures = creatures.stream() .filter(new ColorSelector(Color.RED).and(new MovementSelector(Movement.FLYING))) .collect(Collectors.toList()); redAndFlyingCreatures.stream().forEach(c -> LOGGER.info(c.toString())); }  static void main(String[] args);  }