/* ----------------------------------------
 * Origin  : GFI INFORMATIQUE 
 * Project : CDPP Propagation Tool 
 * ----------------------------------------
 * History 
 * Version : 01/05/2015 : SCA : V2.1
 * Creation 
 * Version : 24/03/2016 : SCA : V2.2 (PSWS-H2020)
 * Add comets
 * ----------------------------------------
 */
package fr.tlse.irap.spaceElement;

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

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

@XmlRootElement
public class SpaceElementWrapper {

	private List<Probe> probes;
	private List<Planet> planets;
	private List<Comet> comets;
	private Sun sun;

	public SpaceElementWrapper() {
		this.probes = new ArrayList<Probe>();
		this.planets = new ArrayList<Planet>();
		this.comets = new ArrayList<Comet>();
	}

	@XmlElement
	public List<SpaceElement> getSpaceElements() {
		List<SpaceElement> spaceElements = new ArrayList<SpaceElement>();
		if (sun != null) {
			spaceElements.add(sun);
		}
		spaceElements.addAll(planets);
		spaceElements.addAll(probes);
		spaceElements.addAll(comets);
		return spaceElements;
	}

	@XmlElement
	public List<Probe> getProbes() {
		return probes;
	}

	public void setProbes(List<Probe> probes) {
		this.probes = probes;
	}

	@XmlElement
	public List<Planet> getPlanets() {
		return planets;
	}

	public void setPlanets(List<Planet> planets) {
		this.planets = planets;
	}

	@XmlElement
	public List<Comet> getComets() {
		return comets;
	}

	public void setComets(List<Comet> comets) {
		this.comets = comets;
	}

	public Sun getSun() {
		return sun;
	}

	public void setSun(Sun sun) {
		this.sun = sun;
	}

	public Probe getProbe(String name) {
		for (Probe element : probes) {
			if (element.getName().contains(name))
				return element;
		}
		return null;
	}

	public Probe getProbe(int id) {
		for (Probe element : probes) {
			if (element.getId() == id)
				return element;
		}
		return null;
	}

	public Planet getPlanet(String name) {
		for (Planet element : planets) {
			if (element.getName().contains(name))
				return element;
		}
		return null;
	}
	
	public Comet getComet(String name) {
		for (Comet element : comets) {
			if (element.getName().contains(name))
				return element;
		}
		return null;
	}

	public Comet getComet(int id) {
		for (Comet element : comets) {
			if (element.getId() == id)
				return element;
		}
		return null;
	}

}
