diff --git a/src/main/java/algoLike/pull/HandsA.java b/src/main/java/algoLike/pull/HandsA.java index 9d3f876..12bd636 100644 --- a/src/main/java/algoLike/pull/HandsA.java +++ b/src/main/java/algoLike/pull/HandsA.java @@ -1,37 +1,31 @@ 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.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.core.MediaType; import java.util.*; +import javax.ws.rs.*; +import javax.ws.rs.client.*; +import javax.ws.rs.core.*; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.core.JsonProcessingException; +import pushPullRefactor.*; @Path("/handsA") @Resource("handsA") @Component public class HandsA { - private final Client client = ClientBuilder.newClient(); + private Client client = ClientBuilder.newClient(); private Map.Entry resultByDrawingA; private Map.Entry resultByDrawingB; private Map.Entry> resultBySelectingA; private Map.Entry> resultBySelectingB; @State private List> value = new ArrayList>(); - @Path("/resultByDrawingA") @POST - @Message({"resultByDrawingA", "deck"}) + @Message({"resultByDrawingA","deck"}) public void updateResultByDrawingA(@FormParam("resultByDrawingA") String resultByDrawingA_json, @FormParam("deck") List deck_json) throws JsonProcessingException { List> deck = new ArrayList<>(); - for (String str : deck_json) { + for (String str: deck_json) { Map i = new ObjectMapper().readValue(str, HashMap.class); deck.add(i.entrySet().iterator().next()); } @@ -52,15 +46,13 @@ temp_if2 = this.value; } this.value = temp_if2; - } - @Path("/resultByDrawingB") @POST - @Message({"resultByDrawingB", "deck"}) + @Message({"resultByDrawingB","deck"}) public void updateResultByDrawingB(@FormParam("resultByDrawingB") String resultByDrawingB_json, @FormParam("deck") List deck_json) throws JsonProcessingException { List> deck = new ArrayList<>(); - for (String str : deck_json) { + for (String str: deck_json) { Map i = new ObjectMapper().readValue(str, HashMap.class); deck.add(i.entrySet().iterator().next()); } @@ -72,15 +64,13 @@ this.resultByDrawingB = resultByDrawingB; List> temp_if3; if (resultByDrawingB.getKey()) { - this.value.set(resultByDrawingB.getValue(), new AbstractMap.SimpleEntry<>(this.value.get(resultByDrawingB.getValue()).getKey(), true)); + this.value.set(resultByDrawingB.getValue(),new AbstractMap.SimpleEntry<>(this.value.get(resultByDrawingB.getValue()).getKey(), true)); temp_if3 = this.value; } else { temp_if3 = this.value; } this.value = temp_if3; - } - @Path("/resultBySelectingA") @POST @Message({"resultBySelecting"}) @@ -95,13 +85,11 @@ if (resultBySelectingA.getKey()) { temp_if4 = this.value; } else { - this.value.set(resultBySelectingA.getValue().getValue(), new AbstractMap.SimpleEntry<>(this.value.get(resultBySelectingA.getValue().getValue()).getKey(), true)); + this.value.set(resultBySelectingA.getValue().getValue(),new AbstractMap.SimpleEntry<>(this.value.get(resultBySelectingA.getValue().getValue()).getKey(), true)); temp_if4 = this.value; } this.value = temp_if4; - } - @Path("/resultBySelectingB") @POST @Message({"resultBySelectingB"}) @@ -114,15 +102,13 @@ this.resultBySelectingB = resultBySelectingB; List> temp_if6; if (resultBySelectingB.getKey()) { - this.value.set(resultBySelectingB.getValue().getKey(), new AbstractMap.SimpleEntry<>(this.value.get(resultBySelectingB.getValue().getKey()).getKey(), true)); + this.value.set(resultBySelectingB.getValue().getKey(),new AbstractMap.SimpleEntry<>(this.value.get(resultBySelectingB.getValue().getKey()).getKey(), true)); temp_if6 = this.value; } else { temp_if6 = this.value; } this.value = temp_if6; - } - @Produces(MediaType.APPLICATION_JSON) @GET @Getter