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; @Path("/resultBySelectingB") @Component public class ResultBySelectingB { private Client client = ClientBuilder.newClient(); private Map.Entry<Boolean, Map.Entry<Integer, Integer>> value; @PUT public void selectAndAttackB(@FormParam("t") int t, @FormParam("g") int g, @FormParam("a") List<Map.Entry<Integer, Boolean>> 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<Form> 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 public Map.Entry<Boolean, Map.Entry<Integer, Integer>> getValue() { return value; } }