mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-18 17:26:44 +00:00
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
@@ -54,10 +54,10 @@ public class App {
|
||||
* Can add a List with enum Actions for variable scenarios.
|
||||
*/
|
||||
public static void scenario(Servant servant, int compliment) {
|
||||
King k = new King();
|
||||
Queen q = new Queen();
|
||||
var k = new King();
|
||||
var q = new Queen();
|
||||
|
||||
List<Royalty> guests = List.of(k, q);
|
||||
var guests = List.of(k, q);
|
||||
|
||||
// feed
|
||||
servant.feed(k);
|
||||
@@ -69,9 +69,7 @@ public class App {
|
||||
servant.giveCompliments(guests.get(compliment));
|
||||
|
||||
// outcome of the night
|
||||
for (Royalty r : guests) {
|
||||
r.changeMood();
|
||||
}
|
||||
guests.forEach(Royalty::changeMood);
|
||||
|
||||
// check your luck
|
||||
if (servant.checkIfYouWillBeHanged(guests)) {
|
||||
|
||||
@@ -55,13 +55,6 @@ public class Servant {
|
||||
* Check if we will be hanged.
|
||||
*/
|
||||
public boolean checkIfYouWillBeHanged(List<Royalty> tableGuests) {
|
||||
boolean anotherDay = true;
|
||||
for (Royalty r : tableGuests) {
|
||||
if (!r.getMood()) {
|
||||
anotherDay = false;
|
||||
}
|
||||
}
|
||||
|
||||
return anotherDay;
|
||||
return tableGuests.stream().allMatch(Royalty::getMood);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user