diff --git a/src/main/java/algoLike/pull/AttackerA.java b/src/main/java/algoLike/pull/AttackerA.java new file mode 100644 index 0000000..c29cb71 --- /dev/null +++ b/src/main/java/algoLike/pull/AttackerA.java @@ -0,0 +1,32 @@ +package algoLike.push; + +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/attackerA") +@Component +@Resource("attackerA") +public class AttackerA { + @State + private int value; + @PUT + @Message({}) + public void setAttackerA(@FormParam("a") int a) { + this.value = a; + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public int getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/AttackerB.java b/src/main/java/algoLike/pull/AttackerB.java new file mode 100644 index 0000000..5d308f3 --- /dev/null +++ b/src/main/java/algoLike/pull/AttackerB.java @@ -0,0 +1,32 @@ +package algoLike.push; + +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/attackerB") +@Component +@Resource("attackerB") +public class AttackerB { + @State + private int value; + @PUT + @Message({}) + public void setAttackerB(@FormParam("b") int b) { + this.value = b; + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public int getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/Deck.java b/src/main/java/algoLike/pull/Deck.java new file mode 100644 index 0000000..ff3fc89 --- /dev/null +++ b/src/main/java/algoLike/pull/Deck.java @@ -0,0 +1,57 @@ +package algoLike.push; + +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/deck") +@Component +@Resource("deck") +public class Deck { + private Map.Entry resultByDrawingA; + private Map.Entry resultByDrawingB; + @State + private List> value = new ArrayList>(); + @Path("/resultByDrawingA") + @POST + @Message({"resultByDrawingA"}) + public void updateResultByDrawingA(@FormParam("resultByDrawingA") String resultByDrawingA_json) throws JsonProcessingException { + Map.Entry resultByDrawingA; + { + Map i = new ObjectMapper().readValue(resultByDrawingA_json, HashMap.class); + resultByDrawingA = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); + } + this.resultByDrawingA = resultByDrawingA; + this.value = this.value.subList(1, this.value.size()); + } + @Path("/resultByDrawingB") + @POST + @Message({"resultByDrawingB"}) + public void updateResultByDrawingB(@FormParam("resultByDrawingB") String resultByDrawingB_json) throws JsonProcessingException { + Map.Entry resultByDrawingB; + { + Map i = new ObjectMapper().readValue(resultByDrawingB_json, HashMap.class); + resultByDrawingB = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); + } + this.resultByDrawingB = resultByDrawingB; + this.value = this.value.subList(1, this.value.size()); + } + @POST + public void addCard(@FormParam("num") Integer num) { + this.value.add(0, new AbstractMap.SimpleEntry<>(num, false)); + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public List> getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/GuessA.java b/src/main/java/algoLike/pull/GuessA.java new file mode 100644 index 0000000..f965a01 --- /dev/null +++ b/src/main/java/algoLike/pull/GuessA.java @@ -0,0 +1,30 @@ +package algoLike.push; + +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.Getter; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/guessA") +@Component +@Resource("guessA") +public class GuessA { + @State + private int value = 0; + @PUT + public void setGuessA(@FormParam("a") int a) { + this.value = a; + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public int getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/GuessB.java b/src/main/java/algoLike/pull/GuessB.java new file mode 100644 index 0000000..958c492 --- /dev/null +++ b/src/main/java/algoLike/pull/GuessB.java @@ -0,0 +1,32 @@ +package algoLike.push; + +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/guessB") +@Component +@Resource("guessB") +public class GuessB { + @State + private int value = 0; + @PUT + @Message({}) + public void setGuessB(@FormParam("b") int b) { + this.value = b; + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public int getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/HandsA.java b/src/main/java/algoLike/pull/HandsA.java new file mode 100644 index 0000000..6164918 --- /dev/null +++ b/src/main/java/algoLike/pull/HandsA.java @@ -0,0 +1,122 @@ +package algoLike.push; + +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 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"}) + public void updateResultByDrawingA(@FormParam("resultByDrawingA") String resultByDrawingA_json, @FormParam("deck") List deck_json) throws JsonProcessingException { + List> deck = new ArrayList<>(); + for (String str: deck_json) { + Map i = new ObjectMapper().readValue(str, HashMap.class); + deck.add(i.entrySet().iterator().next()); + } + Map.Entry resultByDrawingA; + { + Map i = new ObjectMapper().readValue(resultByDrawingA_json, HashMap.class); + resultByDrawingA = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); + } + this.resultByDrawingA = resultByDrawingA; + List> temp_if2; + if (resultByDrawingA.getKey()) { + this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), false)); + this.value.sort(Comparator.comparing(Map.Entry::getKey)); + temp_if2 = this.value; + } else { + this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), true)); + this.value.sort(Comparator.comparing(Map.Entry::getKey)); + temp_if2 = this.value; + } + this.value = temp_if2; + + } + @Path("/resultByDrawingB") + @POST + @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) { + Map i = new ObjectMapper().readValue(str, HashMap.class); + deck.add(i.entrySet().iterator().next()); + } + Map.Entry resultByDrawingB; + { + Map i = new ObjectMapper().readValue(resultByDrawingB_json, HashMap.class); + resultByDrawingB = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); + } + this.resultByDrawingB = resultByDrawingB; + List> temp_if3; + if (resultByDrawingB.getKey()) { + 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"}) + public void updateResultBySelectingA(@FormParam("resultBySelectingA") String resultBySelectingA_json) throws JsonProcessingException { + Map.Entry> resultBySelectingA; + { + Map> i = new ObjectMapper().readValue(resultBySelectingA_json, HashMap.class); + resultBySelectingA = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue())); + } + this.resultBySelectingA = resultBySelectingA; + List> temp_if4; + 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)); + temp_if4 = this.value; + } + this.value = temp_if4; + + } + @Path("/resultBySelectingB") + @POST + @Message({"resultBySelectingB"}) + public void updateResultBySelectingB(@FormParam("resultBySelectingB") String resultBySelectingB_json) throws JsonProcessingException { + Map.Entry> resultBySelectingB; + { + Map> i = new ObjectMapper().readValue(resultBySelectingB_json, HashMap.class); + resultBySelectingB = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue())); + } + 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)); + temp_if6 = this.value; + } else { + temp_if6 = this.value; + } + this.value = temp_if6; + + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public List> getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/HandsB.java b/src/main/java/algoLike/pull/HandsB.java new file mode 100644 index 0000000..f43e5c1 --- /dev/null +++ b/src/main/java/algoLike/pull/HandsB.java @@ -0,0 +1,145 @@ +package algoLike.push; + +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("/handsB") +@Component +@Resource("handsB") +public class HandsB { + private Client client = ClientBuilder.newClient(); + private Map.Entry resultByDrawingB; + private Map.Entry resultByDrawingA; + private Map.Entry> resultBySelectingB; + private Map.Entry> resultBySelectingA; + @State + private List> value = new ArrayList>(); + @PushReference("loseB") + @Pullable("direct") + private String loseB = "/loseB"; + @Path("/resultByDrawingB") + @POST + @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) { + Map i = new ObjectMapper().readValue(str, HashMap.class); + deck.add(i.entrySet().iterator().next()); + } + Map.Entry resultByDrawingB; + { + Map i = new ObjectMapper().readValue(resultByDrawingB_json, HashMap.class); + resultByDrawingB = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); + } + this.resultByDrawingB = resultByDrawingB; + List> temp_if0; + if (resultByDrawingB.getKey()) { + this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), false)); + this.value.sort(Comparator.comparing(Map.Entry::getKey)); + temp_if0 = this.value; + } else { + this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), true)); + this.value.sort(Comparator.comparing(Map.Entry::getKey)); + temp_if0 = this.value; + } + this.value = temp_if0; + Form form = new Form(); + for (Map.Entry i: this.value) { + form.param("handsB", new ObjectMapper().writeValueAsString(i)); + } + Entity
entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + String result = client.target("http://localhost:8080").path(loseB).request().put(entity, String.class); + } + @Path("/resultByDrawingA") + @POST + @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) { + Map i = new ObjectMapper().readValue(str, HashMap.class); + deck.add(i.entrySet().iterator().next()); + } + Map.Entry resultByDrawingA; + { + Map i = new ObjectMapper().readValue(resultByDrawingA_json, HashMap.class); + resultByDrawingA = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); + } + this.resultByDrawingA = resultByDrawingA; + List> temp_if1; + if (resultByDrawingA.getKey()) { + this.value.set(resultByDrawingA.getValue(),new AbstractMap.SimpleEntry<>(this.value.get(resultByDrawingA.getValue()).getKey(), true)); + temp_if1 = this.value; + } else { + temp_if1 = this.value; + } + this.value = temp_if1; + Form form = new Form(); + for (Map.Entry i: this.value) { + form.param("handsB", new ObjectMapper().writeValueAsString(i)); + } + Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + String result = client.target("http://localhost:8080").path(loseB).request().put(entity, String.class); + } + @Path("/resultBySelectingB") + @POST + @Message({"resultBySelectingA"}) + public void updateResultBySelectingB(@FormParam("resultBySelectingB") String resultBySelectingB_json) throws JsonProcessingException { + Map.Entry> resultBySelectingB; + { + Map> i = new ObjectMapper().readValue(resultBySelectingB_json, HashMap.class); + resultBySelectingB = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue())); + } + this.resultBySelectingB = resultBySelectingB; + List> temp_if5; + if (resultBySelectingB.getKey()) { + temp_if5 = this.value; + } else { + this.value.set(resultBySelectingB.getValue().getValue(),new AbstractMap.SimpleEntry<>(this.value.get(resultBySelectingB.getValue().getValue()).getKey(), true)); + temp_if5 = this.value; + } + this.value = temp_if5; + Form form = new Form(); + for (Map.Entry i: this.value) { + form.param("handsB", new ObjectMapper().writeValueAsString(i)); + } + Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + String result = client.target("http://localhost:8080").path(loseB).request().put(entity, String.class); + } + @Path("/resultBySelectingA") + @POST + @Message({"resultBySelectingA"}) + public void updateResultBySelectingA(@FormParam("resultBySelectingA") String resultBySelectingA_json) throws JsonProcessingException { + Map.Entry> resultBySelectingA; + { + Map> i = new ObjectMapper().readValue(resultBySelectingA_json, HashMap.class); + resultBySelectingA = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue())); + } + this.resultBySelectingA = resultBySelectingA; + List> temp_if7; + if (resultBySelectingA.getKey()) { + this.value.set(resultBySelectingA.getValue().getKey(),new AbstractMap.SimpleEntry<>(this.value.get(resultBySelectingA.getValue().getKey()).getKey(), true)); + temp_if7 = this.value; + } else { + temp_if7 = this.value; + } + this.value = temp_if7; + Form form = new Form(); + for (Map.Entry i: this.value) { + form.param("handsB", new ObjectMapper().writeValueAsString(i)); + } + Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + String result = client.target("http://localhost:8080").path(loseB).request().put(entity, String.class); + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public List> getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/LoseA.java b/src/main/java/algoLike/pull/LoseA.java new file mode 100644 index 0000000..9210e1a --- /dev/null +++ b/src/main/java/algoLike/pull/LoseA.java @@ -0,0 +1,39 @@ +package algoLike.push; + +import java.util.*; +import java.util.stream.Collectors; +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/loseA") +@Component +@Resource("loseA") +public class LoseA { + private client client = ClientBUilder.newClient(); + + @PullReference("handsA") + @Pushable + private String handsA = "/handsA"; + + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public boolean getValue() { + List> handsA_json = client.target("http:localhost:8080").path(this.handsA).request().get(ArrayList.class); + List> handsA = new ArrayList<>(); + for (Map i : handsA_json) { + handsA.add(new AbstractMap.SimpleEntry<>( + Integer.parseInt(i.entrySet().iterator().next().getKey()), + i.entrySet().iterator().next().getValue())); + } + return (handsA.stream().filter(item -> item.getValue()==false).collect(Collectors.toList()).size()==0); + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/LoseB.java b/src/main/java/algoLike/pull/LoseB.java new file mode 100644 index 0000000..887312b --- /dev/null +++ b/src/main/java/algoLike/pull/LoseB.java @@ -0,0 +1,38 @@ +package algoLike.push; + +import java.util.*; +import java.util.stream.Collectors; +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/loseB") +@Component +@Resource("loseB") +public class LoseB { + @State + private boolean value; + @PUT + @Message({"handsB"}) + public void updateHandsB(@FormParam("handsB") List handsB_json) throws JsonProcessingException { + List> handsB = new ArrayList<>(); + for (String str: handsB_json) { + Map 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; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/ResultByDrawingA.java b/src/main/java/algoLike/pull/ResultByDrawingA.java new file mode 100644 index 0000000..15af945 --- /dev/null +++ b/src/main/java/algoLike/pull/ResultByDrawingA.java @@ -0,0 +1,56 @@ +package algoLike.push; + +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/resultByDrawingA") +@Component +@Resource("resultByDrawingA") +public class ResultByDrawingA { + private Client client = ClientBuilder.newClient(); + @State + private Map.Entry value; + @PUT + @Message({}) + public void drawAndAttackA(@FormParam("g") int g, @FormParam("b") List> b, @FormParam("t") int t) throws JsonProcessingException { + this.value = new AbstractMap.SimpleEntry<>((b.get(t).getKey()==g), t); + List> deck_json = client.target("http://localhost:8080").path("/deck").request().get(ArrayList.class); + List> deck = new ArrayList<>(); + for (Map i: deck_json) { + deck.add(i.entrySet().iterator().next()); + } + Form form = new Form(); + form.param("resultByDrawingA", new ObjectMapper().writeValueAsString(this.value)); + Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + String result = client.target("http://localhost:8080").path("/deck/resultByDrawingA").request().post(entity, String.class); + form = new Form(); + form.param("resultByDrawingA", new ObjectMapper().writeValueAsString(this.value)); + for (Map.Entry i: deck) { + form.param("deck", new ObjectMapper().writeValueAsString(i)); + } + entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + result = client.target("http://localhost:8080").path("/handsB/resultByDrawingA").request().post(entity, String.class); + form = new Form(); + form.param("resultByDrawingA", new ObjectMapper().writeValueAsString(this.value)); + for (Map.Entry i: deck) { + form.param("deck", new ObjectMapper().writeValueAsString(i)); + } + entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + result = client.target("http://localhost:8080").path("/handsA/resultByDrawingA").request().post(entity, String.class); + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public Map.Entry getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/ResultByDrawingB.java b/src/main/java/algoLike/pull/ResultByDrawingB.java new file mode 100644 index 0000000..b333d52 --- /dev/null +++ b/src/main/java/algoLike/pull/ResultByDrawingB.java @@ -0,0 +1,56 @@ +package algoLike.push; + +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/resultByDrawingB") +@Component +@Resource("resultByDrawingB") +public class ResultByDrawingB { + private Client client = ClientBuilder.newClient(); + @State + private Map.Entry value; + @PUT + @Message({}) + public void drawAndAttackB(@FormParam("g") int g, @FormParam("a") List> a, @FormParam("t") int t) throws JsonProcessingException { + this.value = new AbstractMap.SimpleEntry<>((a.get(t).getKey()==g), t); + List> deck_json = client.target("http://localhost:8080").path("/deck").request().get(ArrayList.class); + List> deck = new ArrayList<>(); + for (Map i: deck_json) { + deck.add(i.entrySet().iterator().next()); + } + Form form = new Form(); + form.param("resultByDrawingB", new ObjectMapper().writeValueAsString(this.value)); + for (Map.Entry i: deck) { + form.param("deck", new ObjectMapper().writeValueAsString(i)); + } + Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + String result = client.target("http://localhost:8080").path("/handsB/resultByDrawingB").request().post(entity, String.class); + form = new Form(); + form.param("resultByDrawingB", new ObjectMapper().writeValueAsString(this.value)); + entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + result = client.target("http://localhost:8080").path("/deck/resultByDrawingB").request().post(entity, String.class); + form = new Form(); + form.param("resultByDrawingB", new ObjectMapper().writeValueAsString(this.value)); + for (Map.Entry i: deck) { + form.param("deck", new ObjectMapper().writeValueAsString(i)); + } + entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + result = client.target("http://localhost:8080").path("/handsA/resultByDrawingB").request().post(entity, String.class); + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public Map.Entry getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/ResultBySelectingA.java b/src/main/java/algoLike/pull/ResultBySelectingA.java new file mode 100644 index 0000000..3cd80c7 --- /dev/null +++ b/src/main/java/algoLike/pull/ResultBySelectingA.java @@ -0,0 +1,41 @@ +package algoLike.push; + +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/resultBySelectingA") +@Component +@Resource("resultBySelectingA") +public class ResultBySelectingA { + private Client client = ClientBuilder.newClient(); + @State + private Map.Entry> value; + @PUT + @Message({}) + public void selectAndAttackA(@FormParam("t") int t, @FormParam("g") int g, @FormParam("b") List> b, @FormParam("a") int a) throws JsonProcessingException { + this.value = new AbstractMap.SimpleEntry<>((b.get(t).getKey()==g), new AbstractMap.SimpleEntry<>(t, a)); + Form form = new Form(); + form.param("resultBySelectingA", new ObjectMapper().writeValueAsString(this.value)); + Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + String result = client.target("http://localhost:8080").path("/handsA/resultBySelectingA").request().post(entity, String.class); + form = new Form(); + form.param("resultBySelectingA", new ObjectMapper().writeValueAsString(this.value)); + entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + result = client.target("http://localhost:8080").path("/handsB/resultBySelectingA").request().post(entity, String.class); + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public Map.Entry> getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/ResultBySelectingB.java b/src/main/java/algoLike/pull/ResultBySelectingB.java new file mode 100644 index 0000000..7c62a32 --- /dev/null +++ b/src/main/java/algoLike/pull/ResultBySelectingB.java @@ -0,0 +1,42 @@ +package algoLike.push; + +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 org.springframework.stereotype.Repository; +import pushPullRefactor.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/resultBySelectingB") +@Component +@Resource("resultBySelecting") +public class ResultBySelectingB { + private Client client = ClientBuilder.newClient(); + @State + private Map.Entry> value; + @PUT + @Message({}) + public void selectAndAttackB(@FormParam("t") int t, @FormParam("g") int g, @FormParam("a") List> a, @FormParam("atk") int atk) throws JsonProcessingException { + this.value = new AbstractMap.SimpleEntry<>((a.get(t).getKey()==g), new AbstractMap.SimpleEntry<>(t, atk) ); + Form form = new Form(); + form.param("resultBySelectingB", new ObjectMapper().writeValueAsString(this.value)); + Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + String result = client.target("http://localhost:8080").path("/handsB/resultBySelectingB").request().post(entity, String.class); + form = new Form(); + form.param("resultBySelectingB", new ObjectMapper().writeValueAsString(this.value)); + entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); + result = client.target("http://localhost:8080").path("/handsA/resultBySelectingB").request().post(entity, String.class); + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public Map.Entry> getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/TargetA.java b/src/main/java/algoLike/pull/TargetA.java new file mode 100644 index 0000000..3a4d297 --- /dev/null +++ b/src/main/java/algoLike/pull/TargetA.java @@ -0,0 +1,32 @@ +package algoLike.push; + +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/targetA") +@Component +@Resource("targetA") +public class TargetA { + @State + private int value; + @PUT + @Message({}) + public void setTargetA(@FormParam("a") int a) { + this.value = a; + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public int getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/pull/TargetB.java b/src/main/java/algoLike/pull/TargetB.java new file mode 100644 index 0000000..34df139 --- /dev/null +++ b/src/main/java/algoLike/pull/TargetB.java @@ -0,0 +1,32 @@ +package algoLike.push; + +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.Getter; +import pushPullRefactor.Message; +import pushPullRefactor.Resource; +import pushPullRefactor.State; + +@Path("/targetB") +@Component +@Resource("targetB") +public class TargetB { + @State + private int value; + @PUT + @Message({}) + public void setTargetB(@FormParam("b") int b) { + this.value = b; + } + @Produces(MediaType.APPLICATION_JSON) + @GET + @Getter + public int getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/algoLike/push/AttackerA.java b/src/main/java/algoLike/push/AttackerA.java deleted file mode 100644 index c29cb71..0000000 --- a/src/main/java/algoLike/push/AttackerA.java +++ /dev/null @@ -1,32 +0,0 @@ -package algoLike.push; - -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/attackerA") -@Component -@Resource("attackerA") -public class AttackerA { - @State - private int value; - @PUT - @Message({}) - public void setAttackerA(@FormParam("a") int a) { - this.value = a; - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public int getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/AttackerB.java b/src/main/java/algoLike/push/AttackerB.java deleted file mode 100644 index 5d308f3..0000000 --- a/src/main/java/algoLike/push/AttackerB.java +++ /dev/null @@ -1,32 +0,0 @@ -package algoLike.push; - -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/attackerB") -@Component -@Resource("attackerB") -public class AttackerB { - @State - private int value; - @PUT - @Message({}) - public void setAttackerB(@FormParam("b") int b) { - this.value = b; - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public int getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/Deck.java b/src/main/java/algoLike/push/Deck.java deleted file mode 100644 index ff3fc89..0000000 --- a/src/main/java/algoLike/push/Deck.java +++ /dev/null @@ -1,57 +0,0 @@ -package algoLike.push; - -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/deck") -@Component -@Resource("deck") -public class Deck { - private Map.Entry resultByDrawingA; - private Map.Entry resultByDrawingB; - @State - private List> value = new ArrayList>(); - @Path("/resultByDrawingA") - @POST - @Message({"resultByDrawingA"}) - public void updateResultByDrawingA(@FormParam("resultByDrawingA") String resultByDrawingA_json) throws JsonProcessingException { - Map.Entry resultByDrawingA; - { - Map i = new ObjectMapper().readValue(resultByDrawingA_json, HashMap.class); - resultByDrawingA = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); - } - this.resultByDrawingA = resultByDrawingA; - this.value = this.value.subList(1, this.value.size()); - } - @Path("/resultByDrawingB") - @POST - @Message({"resultByDrawingB"}) - public void updateResultByDrawingB(@FormParam("resultByDrawingB") String resultByDrawingB_json) throws JsonProcessingException { - Map.Entry resultByDrawingB; - { - Map i = new ObjectMapper().readValue(resultByDrawingB_json, HashMap.class); - resultByDrawingB = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); - } - this.resultByDrawingB = resultByDrawingB; - this.value = this.value.subList(1, this.value.size()); - } - @POST - public void addCard(@FormParam("num") Integer num) { - this.value.add(0, new AbstractMap.SimpleEntry<>(num, false)); - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public List> getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/GuessA.java b/src/main/java/algoLike/push/GuessA.java deleted file mode 100644 index f965a01..0000000 --- a/src/main/java/algoLike/push/GuessA.java +++ /dev/null @@ -1,30 +0,0 @@ -package algoLike.push; - -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.Getter; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/guessA") -@Component -@Resource("guessA") -public class GuessA { - @State - private int value = 0; - @PUT - public void setGuessA(@FormParam("a") int a) { - this.value = a; - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public int getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/GuessB.java b/src/main/java/algoLike/push/GuessB.java deleted file mode 100644 index 958c492..0000000 --- a/src/main/java/algoLike/push/GuessB.java +++ /dev/null @@ -1,32 +0,0 @@ -package algoLike.push; - -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/guessB") -@Component -@Resource("guessB") -public class GuessB { - @State - private int value = 0; - @PUT - @Message({}) - public void setGuessB(@FormParam("b") int b) { - this.value = b; - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public int getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/HandsA.java b/src/main/java/algoLike/push/HandsA.java deleted file mode 100644 index 707799f..0000000 --- a/src/main/java/algoLike/push/HandsA.java +++ /dev/null @@ -1,145 +0,0 @@ -package algoLike.push; - -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 Client client = ClientBuilder.newClient(); - private Map.Entry resultByDrawingA; - private Map.Entry resultByDrawingB; - private Map.Entry> resultBySelectingA; - private Map.Entry> resultBySelectingB; - @PushReference("loseA") - @Pullable("direct") - private String loseA = "/loseA"; - @State - private List> value = new ArrayList>(); - @Path("/resultByDrawingA") - @POST - @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) { - Map i = new ObjectMapper().readValue(str, HashMap.class); - deck.add(i.entrySet().iterator().next()); - } - Map.Entry resultByDrawingA; - { - Map i = new ObjectMapper().readValue(resultByDrawingA_json, HashMap.class); - resultByDrawingA = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); - } - this.resultByDrawingA = resultByDrawingA; - List> temp_if2; - if (resultByDrawingA.getKey()) { - this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), false)); - this.value.sort(Comparator.comparing(Map.Entry::getKey)); - temp_if2 = this.value; - } else { - this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), true)); - this.value.sort(Comparator.comparing(Map.Entry::getKey)); - temp_if2 = this.value; - } - this.value = temp_if2; - Form form = new Form(); - for (Map.Entry i: this.value) { - form.param("handsA", new ObjectMapper().writeValueAsString(i)); - } - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path(loseA).request().put(entity, String.class); - } - @Path("/resultByDrawingB") - @POST - @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) { - Map i = new ObjectMapper().readValue(str, HashMap.class); - deck.add(i.entrySet().iterator().next()); - } - Map.Entry resultByDrawingB; - { - Map i = new ObjectMapper().readValue(resultByDrawingB_json, HashMap.class); - resultByDrawingB = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); - } - this.resultByDrawingB = resultByDrawingB; - List> temp_if3; - if (resultByDrawingB.getKey()) { - 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; - Form form = new Form(); - for (Map.Entry i: this.value) { - form.param("handsA", new ObjectMapper().writeValueAsString(i)); - } - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path(loseA).request().put(entity, String.class); - } - @Path("/resultBySelectingA") - @POST - @Message({"resultBySelecting"}) - public void updateResultBySelectingA(@FormParam("resultBySelectingA") String resultBySelectingA_json) throws JsonProcessingException { - Map.Entry> resultBySelectingA; - { - Map> i = new ObjectMapper().readValue(resultBySelectingA_json, HashMap.class); - resultBySelectingA = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue())); - } - this.resultBySelectingA = resultBySelectingA; - List> temp_if4; - 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)); - temp_if4 = this.value; - } - this.value = temp_if4; - Form form = new Form(); - for (Map.Entry i: this.value) { - form.param("handsA", new ObjectMapper().writeValueAsString(i)); - } - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path(loseA).request().put(entity, String.class); - } - @Path("/resultBySelectingB") - @POST - @Message({"resultBySelectingB"}) - public void updateResultBySelectingB(@FormParam("resultBySelectingB") String resultBySelectingB_json) throws JsonProcessingException { - Map.Entry> resultBySelectingB; - { - Map> i = new ObjectMapper().readValue(resultBySelectingB_json, HashMap.class); - resultBySelectingB = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue())); - } - 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)); - temp_if6 = this.value; - } else { - temp_if6 = this.value; - } - this.value = temp_if6; - Form form = new Form(); - for (Map.Entry i: this.value) { - form.param("handsA", new ObjectMapper().writeValueAsString(i)); - } - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path(loseA).request().put(entity, String.class); - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public List> getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/HandsB.java b/src/main/java/algoLike/push/HandsB.java deleted file mode 100644 index f43e5c1..0000000 --- a/src/main/java/algoLike/push/HandsB.java +++ /dev/null @@ -1,145 +0,0 @@ -package algoLike.push; - -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("/handsB") -@Component -@Resource("handsB") -public class HandsB { - private Client client = ClientBuilder.newClient(); - private Map.Entry resultByDrawingB; - private Map.Entry resultByDrawingA; - private Map.Entry> resultBySelectingB; - private Map.Entry> resultBySelectingA; - @State - private List> value = new ArrayList>(); - @PushReference("loseB") - @Pullable("direct") - private String loseB = "/loseB"; - @Path("/resultByDrawingB") - @POST - @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) { - Map i = new ObjectMapper().readValue(str, HashMap.class); - deck.add(i.entrySet().iterator().next()); - } - Map.Entry resultByDrawingB; - { - Map i = new ObjectMapper().readValue(resultByDrawingB_json, HashMap.class); - resultByDrawingB = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); - } - this.resultByDrawingB = resultByDrawingB; - List> temp_if0; - if (resultByDrawingB.getKey()) { - this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), false)); - this.value.sort(Comparator.comparing(Map.Entry::getKey)); - temp_if0 = this.value; - } else { - this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), true)); - this.value.sort(Comparator.comparing(Map.Entry::getKey)); - temp_if0 = this.value; - } - this.value = temp_if0; - Form form = new Form(); - for (Map.Entry i: this.value) { - form.param("handsB", new ObjectMapper().writeValueAsString(i)); - } - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path(loseB).request().put(entity, String.class); - } - @Path("/resultByDrawingA") - @POST - @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) { - Map i = new ObjectMapper().readValue(str, HashMap.class); - deck.add(i.entrySet().iterator().next()); - } - Map.Entry resultByDrawingA; - { - Map i = new ObjectMapper().readValue(resultByDrawingA_json, HashMap.class); - resultByDrawingA = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue()); - } - this.resultByDrawingA = resultByDrawingA; - List> temp_if1; - if (resultByDrawingA.getKey()) { - this.value.set(resultByDrawingA.getValue(),new AbstractMap.SimpleEntry<>(this.value.get(resultByDrawingA.getValue()).getKey(), true)); - temp_if1 = this.value; - } else { - temp_if1 = this.value; - } - this.value = temp_if1; - Form form = new Form(); - for (Map.Entry i: this.value) { - form.param("handsB", new ObjectMapper().writeValueAsString(i)); - } - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path(loseB).request().put(entity, String.class); - } - @Path("/resultBySelectingB") - @POST - @Message({"resultBySelectingA"}) - public void updateResultBySelectingB(@FormParam("resultBySelectingB") String resultBySelectingB_json) throws JsonProcessingException { - Map.Entry> resultBySelectingB; - { - Map> i = new ObjectMapper().readValue(resultBySelectingB_json, HashMap.class); - resultBySelectingB = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue())); - } - this.resultBySelectingB = resultBySelectingB; - List> temp_if5; - if (resultBySelectingB.getKey()) { - temp_if5 = this.value; - } else { - this.value.set(resultBySelectingB.getValue().getValue(),new AbstractMap.SimpleEntry<>(this.value.get(resultBySelectingB.getValue().getValue()).getKey(), true)); - temp_if5 = this.value; - } - this.value = temp_if5; - Form form = new Form(); - for (Map.Entry i: this.value) { - form.param("handsB", new ObjectMapper().writeValueAsString(i)); - } - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path(loseB).request().put(entity, String.class); - } - @Path("/resultBySelectingA") - @POST - @Message({"resultBySelectingA"}) - public void updateResultBySelectingA(@FormParam("resultBySelectingA") String resultBySelectingA_json) throws JsonProcessingException { - Map.Entry> resultBySelectingA; - { - Map> i = new ObjectMapper().readValue(resultBySelectingA_json, HashMap.class); - resultBySelectingA = new AbstractMap.SimpleEntry<>(Boolean.parseBoolean(i.entrySet().iterator().next().getKey()), new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue())); - } - this.resultBySelectingA = resultBySelectingA; - List> temp_if7; - if (resultBySelectingA.getKey()) { - this.value.set(resultBySelectingA.getValue().getKey(),new AbstractMap.SimpleEntry<>(this.value.get(resultBySelectingA.getValue().getKey()).getKey(), true)); - temp_if7 = this.value; - } else { - temp_if7 = this.value; - } - this.value = temp_if7; - Form form = new Form(); - for (Map.Entry i: this.value) { - form.param("handsB", new ObjectMapper().writeValueAsString(i)); - } - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path(loseB).request().put(entity, String.class); - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public List> getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/LoseA.java b/src/main/java/algoLike/push/LoseA.java deleted file mode 100644 index 1de57b5..0000000 --- a/src/main/java/algoLike/push/LoseA.java +++ /dev/null @@ -1,41 +0,0 @@ -package algoLike.push; - -import java.util.*; -import java.util.stream.Collectors; -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/loseA") -@Component -@Resource("loseA") -public class LoseA { - @State - private boolean value; - @PUT - @Message({"handsA"}) - public void updateHandsA(@FormParam("handsA") List handsA_json) throws JsonProcessingException { - List> handsA = new ArrayList<>(); - for (String str: handsA_json) { - Map i = new ObjectMapper().readValue(str, HashMap.class); - handsA.add(new AbstractMap.SimpleEntry<>( - Integer.parseInt(i.entrySet().iterator().next().getKey()), - i.entrySet().iterator().next().getValue()) - ); - } - this.value = (handsA.stream().filter(item -> item.getValue()==false).collect(Collectors.toList()).size()==0); - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public boolean getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/LoseB.java b/src/main/java/algoLike/push/LoseB.java deleted file mode 100644 index 887312b..0000000 --- a/src/main/java/algoLike/push/LoseB.java +++ /dev/null @@ -1,38 +0,0 @@ -package algoLike.push; - -import java.util.*; -import java.util.stream.Collectors; -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/loseB") -@Component -@Resource("loseB") -public class LoseB { - @State - private boolean value; - @PUT - @Message({"handsB"}) - public void updateHandsB(@FormParam("handsB") List handsB_json) throws JsonProcessingException { - List> handsB = new ArrayList<>(); - for (String str: handsB_json) { - Map 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; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/ResultByDrawingA.java b/src/main/java/algoLike/push/ResultByDrawingA.java deleted file mode 100644 index 15af945..0000000 --- a/src/main/java/algoLike/push/ResultByDrawingA.java +++ /dev/null @@ -1,56 +0,0 @@ -package algoLike.push; - -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/resultByDrawingA") -@Component -@Resource("resultByDrawingA") -public class ResultByDrawingA { - private Client client = ClientBuilder.newClient(); - @State - private Map.Entry value; - @PUT - @Message({}) - public void drawAndAttackA(@FormParam("g") int g, @FormParam("b") List> b, @FormParam("t") int t) throws JsonProcessingException { - this.value = new AbstractMap.SimpleEntry<>((b.get(t).getKey()==g), t); - List> deck_json = client.target("http://localhost:8080").path("/deck").request().get(ArrayList.class); - List> deck = new ArrayList<>(); - for (Map i: deck_json) { - deck.add(i.entrySet().iterator().next()); - } - Form form = new Form(); - form.param("resultByDrawingA", new ObjectMapper().writeValueAsString(this.value)); - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path("/deck/resultByDrawingA").request().post(entity, String.class); - form = new Form(); - form.param("resultByDrawingA", new ObjectMapper().writeValueAsString(this.value)); - for (Map.Entry i: deck) { - form.param("deck", new ObjectMapper().writeValueAsString(i)); - } - entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - result = client.target("http://localhost:8080").path("/handsB/resultByDrawingA").request().post(entity, String.class); - form = new Form(); - form.param("resultByDrawingA", new ObjectMapper().writeValueAsString(this.value)); - for (Map.Entry i: deck) { - form.param("deck", new ObjectMapper().writeValueAsString(i)); - } - entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - result = client.target("http://localhost:8080").path("/handsA/resultByDrawingA").request().post(entity, String.class); - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public Map.Entry getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/ResultByDrawingB.java b/src/main/java/algoLike/push/ResultByDrawingB.java deleted file mode 100644 index b333d52..0000000 --- a/src/main/java/algoLike/push/ResultByDrawingB.java +++ /dev/null @@ -1,56 +0,0 @@ -package algoLike.push; - -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/resultByDrawingB") -@Component -@Resource("resultByDrawingB") -public class ResultByDrawingB { - private Client client = ClientBuilder.newClient(); - @State - private Map.Entry value; - @PUT - @Message({}) - public void drawAndAttackB(@FormParam("g") int g, @FormParam("a") List> a, @FormParam("t") int t) throws JsonProcessingException { - this.value = new AbstractMap.SimpleEntry<>((a.get(t).getKey()==g), t); - List> deck_json = client.target("http://localhost:8080").path("/deck").request().get(ArrayList.class); - List> deck = new ArrayList<>(); - for (Map i: deck_json) { - deck.add(i.entrySet().iterator().next()); - } - Form form = new Form(); - form.param("resultByDrawingB", new ObjectMapper().writeValueAsString(this.value)); - for (Map.Entry i: deck) { - form.param("deck", new ObjectMapper().writeValueAsString(i)); - } - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path("/handsB/resultByDrawingB").request().post(entity, String.class); - form = new Form(); - form.param("resultByDrawingB", new ObjectMapper().writeValueAsString(this.value)); - entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - result = client.target("http://localhost:8080").path("/deck/resultByDrawingB").request().post(entity, String.class); - form = new Form(); - form.param("resultByDrawingB", new ObjectMapper().writeValueAsString(this.value)); - for (Map.Entry i: deck) { - form.param("deck", new ObjectMapper().writeValueAsString(i)); - } - entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - result = client.target("http://localhost:8080").path("/handsA/resultByDrawingB").request().post(entity, String.class); - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public Map.Entry getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/ResultBySelectingA.java b/src/main/java/algoLike/push/ResultBySelectingA.java deleted file mode 100644 index 3cd80c7..0000000 --- a/src/main/java/algoLike/push/ResultBySelectingA.java +++ /dev/null @@ -1,41 +0,0 @@ -package algoLike.push; - -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/resultBySelectingA") -@Component -@Resource("resultBySelectingA") -public class ResultBySelectingA { - private Client client = ClientBuilder.newClient(); - @State - private Map.Entry> value; - @PUT - @Message({}) - public void selectAndAttackA(@FormParam("t") int t, @FormParam("g") int g, @FormParam("b") List> b, @FormParam("a") int a) throws JsonProcessingException { - this.value = new AbstractMap.SimpleEntry<>((b.get(t).getKey()==g), new AbstractMap.SimpleEntry<>(t, a)); - Form form = new Form(); - form.param("resultBySelectingA", new ObjectMapper().writeValueAsString(this.value)); - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path("/handsA/resultBySelectingA").request().post(entity, String.class); - form = new Form(); - form.param("resultBySelectingA", new ObjectMapper().writeValueAsString(this.value)); - entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - result = client.target("http://localhost:8080").path("/handsB/resultBySelectingA").request().post(entity, String.class); - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public Map.Entry> getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/ResultBySelectingB.java b/src/main/java/algoLike/push/ResultBySelectingB.java deleted file mode 100644 index 7c62a32..0000000 --- a/src/main/java/algoLike/push/ResultBySelectingB.java +++ /dev/null @@ -1,42 +0,0 @@ -package algoLike.push; - -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 org.springframework.stereotype.Repository; -import pushPullRefactor.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/resultBySelectingB") -@Component -@Resource("resultBySelecting") -public class ResultBySelectingB { - private Client client = ClientBuilder.newClient(); - @State - private Map.Entry> value; - @PUT - @Message({}) - public void selectAndAttackB(@FormParam("t") int t, @FormParam("g") int g, @FormParam("a") List> a, @FormParam("atk") int atk) throws JsonProcessingException { - this.value = new AbstractMap.SimpleEntry<>((a.get(t).getKey()==g), new AbstractMap.SimpleEntry<>(t, atk) ); - Form form = new Form(); - form.param("resultBySelectingB", new ObjectMapper().writeValueAsString(this.value)); - Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path("/handsB/resultBySelectingB").request().post(entity, String.class); - form = new Form(); - form.param("resultBySelectingB", new ObjectMapper().writeValueAsString(this.value)); - entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - result = client.target("http://localhost:8080").path("/handsA/resultBySelectingB").request().post(entity, String.class); - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public Map.Entry> getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/TargetA.java b/src/main/java/algoLike/push/TargetA.java deleted file mode 100644 index 3a4d297..0000000 --- a/src/main/java/algoLike/push/TargetA.java +++ /dev/null @@ -1,32 +0,0 @@ -package algoLike.push; - -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/targetA") -@Component -@Resource("targetA") -public class TargetA { - @State - private int value; - @PUT - @Message({}) - public void setTargetA(@FormParam("a") int a) { - this.value = a; - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public int getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/algoLike/push/TargetB.java b/src/main/java/algoLike/push/TargetB.java deleted file mode 100644 index 34df139..0000000 --- a/src/main/java/algoLike/push/TargetB.java +++ /dev/null @@ -1,32 +0,0 @@ -package algoLike.push; - -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.Getter; -import pushPullRefactor.Message; -import pushPullRefactor.Resource; -import pushPullRefactor.State; - -@Path("/targetB") -@Component -@Resource("targetB") -public class TargetB { - @State - private int value; - @PUT - @Message({}) - public void setTargetB(@FormParam("b") int b) { - this.value = b; - } - @Produces(MediaType.APPLICATION_JSON) - @GET - @Getter - public int getValue() { - return value; - } -} \ No newline at end of file