From 804d85a8ec9c52c570320f1e3a135b5bc8019d1d Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 22 Jan 2020 23:56:53 +0100 Subject: [PATCH] WIP:The default-options... --- src/main/java/de/juplo/demo/DemoController.java | 9 +++------ src/main/java/de/juplo/demo/Form.java | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/juplo/demo/DemoController.java b/src/main/java/de/juplo/demo/DemoController.java index 52fc4fe..59cc3de 100644 --- a/src/main/java/de/juplo/demo/DemoController.java +++ b/src/main/java/de/juplo/demo/DemoController.java @@ -1,7 +1,6 @@ package de.juplo.demo; -import java.util.LinkedHashMap; import java.util.stream.Collectors; import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; @@ -27,11 +26,9 @@ public class DemoController Form form = new Form(); if (param == null) { - form.map = - new LinkedHashMap<>( - Stream - .of( "foo", "bar" ) - .collect(Collectors.toMap(a -> a, a -> false))); + Stream + .of( "foo", "bar" ) + .forEach(option -> form.map.put(option, false)); } return form; } diff --git a/src/main/java/de/juplo/demo/Form.java b/src/main/java/de/juplo/demo/Form.java index 02fcd78..938446c 100644 --- a/src/main/java/de/juplo/demo/Form.java +++ b/src/main/java/de/juplo/demo/Form.java @@ -1,6 +1,7 @@ package de.juplo.demo; +import java.util.LinkedHashMap; import java.util.Map; import lombok.Data; @@ -14,7 +15,7 @@ public class Form { Boolean option; Inner inner = new Inner(); - Map map; + Map map = new LinkedHashMap<>(); } @Data -- 2.20.1