package algoLike.pull; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.stereotype.Component; import pushPullRefactor.Getter; import pushPullRefactor.Message; import pushPullRefactor.Resource; import pushPullRefactor.State; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @Path("/loseB") @Component @Resource("loseB") public class LoseB { @State private boolean value; @PUT @Message({"handsB"}) public void updateHandsB(@FormParam("handsB") List<String> handsB_json) throws JsonProcessingException { List<Map.Entry<Integer, Boolean>> handsB = new ArrayList<>(); for (String str : handsB_json) { Map<Integer, Boolean> i = new ObjectMapper().readValue(str, HashMap.class); handsB.add(i.entrySet().iterator().next()); } this.value = (handsB.stream().filter(item -> item.getValue() == false).collect(Collectors.toList()).size() == 0); } @Produces(MediaType.APPLICATION_JSON) @GET @Getter public boolean getValue() { return value; } }