2026-04-01 14:34:07 +02:00
|
|
|
package ecoparasite.population;
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
import ecoparasite.input.DataParsing;
|
|
|
|
|
import ecoparasite.input.InvalidParsingException;
|
|
|
|
|
import ecoparasite.input.RawData;
|
|
|
|
|
import ecoparasite.input.RawDataOverflow;
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.HashSet;
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/**
|
|
|
|
|
* Permet de gérer une population selon les années.
|
|
|
|
|
*/
|
|
|
|
|
public class Population implements DataParsing {
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/**
|
|
|
|
|
* Espèce de la population.
|
|
|
|
|
*/
|
|
|
|
|
private String id;
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/**
|
|
|
|
|
* Les informations de la population sur le total.
|
|
|
|
|
*/
|
|
|
|
|
private PopulationArgs total;
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/**
|
|
|
|
|
* Les informations de la population par année.
|
|
|
|
|
* Clé : Année, Valeur : Informations de la population.
|
|
|
|
|
*/
|
|
|
|
|
private HashMap<Integer,PopulationArgs> perYear;
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/**
|
|
|
|
|
* Constructeur.
|
|
|
|
|
* @param id Espèce
|
|
|
|
|
* @param total Les informations totales.
|
|
|
|
|
* @param perYear Les informations par année.
|
|
|
|
|
*/
|
|
|
|
|
public Population(String id, PopulationArgs total, HashMap<Integer,PopulationArgs> perYear) {
|
|
|
|
|
this.id = id;
|
|
|
|
|
this.total = total;
|
|
|
|
|
this.perYear = perYear;
|
|
|
|
|
}
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/**
|
|
|
|
|
* Constructeur.
|
|
|
|
|
* Pour les informations par année, crée une HashMap vide. Devra être rempli après coup.
|
|
|
|
|
* @param id Espèce de la population.
|
|
|
|
|
* @param total Les informations totales.
|
|
|
|
|
*/
|
|
|
|
|
public Population(String id, PopulationArgs total) {
|
|
|
|
|
this.id = id;
|
|
|
|
|
this.total = total;
|
|
|
|
|
this.perYear = new HashMap<>();
|
|
|
|
|
}
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/**
|
|
|
|
|
* Constructeur.
|
|
|
|
|
* Pour les informations du total, sont remplacés par null.
|
|
|
|
|
* Pour les informations par année, crée une HashMap vide. Devra être rempli après coup.
|
|
|
|
|
* @param id Espèce de la population.
|
|
|
|
|
*/
|
|
|
|
|
public Population(String id) {
|
|
|
|
|
this.id = id;
|
|
|
|
|
this.total = null;
|
|
|
|
|
this.perYear = new HashMap<>();
|
|
|
|
|
}
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/*
|
|
|
|
|
GETTERS / SETTERS
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public String getId() {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PopulationArgs getTotal() {
|
|
|
|
|
return total;
|
|
|
|
|
}
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
public HashMap<Integer,PopulationArgs> getPerYear() {
|
|
|
|
|
return perYear;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTotal(PopulationArgs total) {
|
|
|
|
|
this.total = total;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPerYear(HashMap<Integer,PopulationArgs> perYear) {
|
|
|
|
|
this.perYear = perYear;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Raccourci vers les méthodes de DataParsing.
|
|
|
|
|
* @param data Notre objet RawData.
|
|
|
|
|
* @param parseTypeId L'ID de parsing.
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static HashSet<Population> parse(RawData data, int parseTypeId ) throws RawDataOverflow, InvalidParsingException {
|
|
|
|
|
switch (parseTypeId) {
|
|
|
|
|
case 1:
|
|
|
|
|
return PopulationParsing.parseParasitesPeru(data);
|
|
|
|
|
default:
|
|
|
|
|
throw new InvalidParsingException(parseTypeId, Population.class.getSimpleName() );
|
2026-03-31 19:00:19 +02:00
|
|
|
}
|
2026-04-01 14:34:07 +02:00
|
|
|
}
|
2026-03-31 19:00:19 +02:00
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/**
|
|
|
|
|
* Raccourci vers les méthodes de DataParsing.
|
|
|
|
|
* Va par défaut faire ceux des parasites du Perou.
|
|
|
|
|
*
|
|
|
|
|
* @param data Notre objet RawData.
|
|
|
|
|
* @return Notre tableau de populations.
|
|
|
|
|
*/
|
|
|
|
|
public static HashSet<Population> parse(RawData data){
|
|
|
|
|
return PopulationParsing.parseParasitesPeru(data);
|
2026-03-31 19:00:19 +02:00
|
|
|
}
|
2026-04-01 14:34:07 +02:00
|
|
|
|
2026-04-08 10:32:11 +02:00
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|
return String.format( "[%s] - Total: %s", id, total );
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
}
|