MapRoot.java 1.1 KB
package fi.codecrew.moya.rest.pojo;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import fi.codecrew.moya.model.EventMap;

@XmlRootElement
public class MapRoot {

	private List<MapPojo> maps;

	public MapRoot() {

	}

	public MapRoot(List<MapPojo> ret) {
		this.setMaps(ret);
	}

	public List<MapPojo> getMaps() {
		return maps;
	}

	public void setMaps(List<MapPojo> maps) {
		this.maps = maps;
	}

	public static class MapPojo {
		private EventMap map;

		public MapPojo() {
			super();
		}

		public MapPojo(EventMap m) {
			this();
			this.map = m;
		}

		@XmlElement(name = "name")
		public String getName() {
			return map.getName();
		}

		@XmlElement(name = "id")
		public Integer getId() {
			return map.getId();
		}

		@XmlElement(name = "active")
		public boolean isActive() {
			return map.isActive();
		}

	}

	public static MapRoot parseMaps(List<EventMap> eventMaps) {
		List<MapPojo> ret = new ArrayList<>();
		for (EventMap m : eventMaps) {
			ret.add(new MapPojo(m));
		}

		return new MapRoot(ret);
	}
}