Newer
Older
algoLike.push / src / main / java / algoLike / push / Deck.java
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("/deck")
@Component
public class Deck {
	private Map.Entry<Boolean, Integer> resultByDrawingA;
	private Map.Entry<Boolean, Integer> resultByDrawingB;
	private List<Map.Entry<Integer, Boolean>> value = new ArrayList<Map.Entry<Integer, Boolean>>();
	@Path("/resultByDrawingA")
	@POST
	public void updateResultByDrawingA(@FormParam("resultByDrawingA") String resultByDrawingA_json) throws JsonProcessingException {
		Map.Entry<Boolean, Integer> resultByDrawingA;
		{
			Map<String, Integer> 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
	public void updateResultByDrawingB(@FormParam("resultByDrawingB") String resultByDrawingB_json) throws JsonProcessingException {
		Map.Entry<Boolean, Integer> resultByDrawingB;
		{
			Map<String, Integer> 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
	public List<Map.Entry<Integer, Boolean>> getValue() {
		return value;
	}
}