A lot of things².
- Change DataParsing to a generic interface. - Add PartiePoisson - Add comments to Population class.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package ecoparasite.poisson;
|
||||
|
||||
import ecoparasite.input.DataParsing;
|
||||
import ecoparasite.input.InvalidParsingException;
|
||||
import ecoparasite.input.RawData;
|
||||
import ecoparasite.input.RawDataOverflow;
|
||||
|
||||
@@ -24,10 +25,25 @@ public class Mackerel extends Poisson implements DataParsing {
|
||||
super(id, length, null, infestation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implémentation de la fonction parse de DataParsing.
|
||||
* Renvoie un tableau de poissons à partir d'un RawData.
|
||||
*
|
||||
* @param data Notre RawData
|
||||
* @param parseTypeId L'ID du type de parsing, ignoré ici.
|
||||
* @return Le tableau de poissons.
|
||||
* @throws RawDataOverflow Si on a un dépassement de données dans notre RawData.
|
||||
* @throws InvalidParsingException
|
||||
*/
|
||||
public static HashSet<Poisson> parse(RawData data, int parseTypeId) throws RawDataOverflow, InvalidParsingException {
|
||||
return Mackerel.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implémentation de la fonction parse de Dataparsing
|
||||
* @param data
|
||||
* @param data Notre RawData.
|
||||
* @return tableau des poissons
|
||||
* @throws RawDataOverflow Si on a un dépassement de données dans notre RawDataOverflow.
|
||||
*/
|
||||
public static HashSet<Poisson> parse(RawData data) throws RawDataOverflow {
|
||||
|
||||
@@ -39,11 +55,27 @@ public class Mackerel extends Poisson implements DataParsing {
|
||||
for (int i = 0; i < data.getData().getFirst().size(); i++) {
|
||||
temp = data.getEntry(i);
|
||||
Poisson newP = new Mackerel(temp.get("Sample_code"),valueOf(temp.get("StandardLength")),valueOf(temp.get("NParasitesViscera")));
|
||||
|
||||
newP.setFishParts( Mackerel.parsePartiePoisson(temp) );
|
||||
fishSet.add(newP);
|
||||
}
|
||||
|
||||
|
||||
return fishSet;
|
||||
}
|
||||
|
||||
private static HashSet<PartiePoisson> parsePartiePoisson(HashMap<String,String> entry){
|
||||
|
||||
HashSet<PartiePoisson> response = new HashSet<>();
|
||||
|
||||
for( String k: entry.keySet() ){
|
||||
if( k.contains( "Anisakis_" ) ){
|
||||
String bodyPart = k.split( "Anisakis_" )[1];
|
||||
Double value = valueOf(entry.get(k));
|
||||
PartiePoisson p = new PartiePoisson(bodyPart, value);
|
||||
response.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ecoparasite.poisson;
|
||||
|
||||
import ecoparasite.input.DataParsing;
|
||||
import ecoparasite.input.InvalidParsingException;
|
||||
import ecoparasite.input.RawData;
|
||||
import ecoparasite.input.RawDataOverflow;
|
||||
|
||||
@@ -24,10 +25,24 @@ public class Merlu extends Poisson implements DataParsing {
|
||||
super(id, length, null, infestation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implémentation de la fonction parse de DataParsing.
|
||||
* Renvoie un tableau de poissons à partir d'un RawData.
|
||||
*
|
||||
* @param data Notre RawData
|
||||
* @param parseTypeId L'ID du type de parsing, ignoré ici.
|
||||
* @return Le tableau de poissons.
|
||||
* @throws RawDataOverflow Si on a un dépassement de données dans notre RawData.
|
||||
*/
|
||||
public static HashSet<Poisson> parse(RawData data, int parseTypeId) throws RawDataOverflow, InvalidParsingException {
|
||||
return Mackerel.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implémentation de la fonction parse de Dataparsing
|
||||
* @param data
|
||||
* @param data Notre RawData
|
||||
* @return tableau des poissons
|
||||
* @throws RawDataOverflow Si on a un dépassement des données de notre objet RawData.
|
||||
*/
|
||||
public static HashSet<Poisson> parse(RawData data) throws RawDataOverflow {
|
||||
|
||||
|
||||
@@ -1,4 +1,61 @@
|
||||
package ecoparasite.poisson;
|
||||
|
||||
public abstract class PartiePoisson {
|
||||
/**
|
||||
* Permet d'illustrer une partie d'un poisson.
|
||||
*/
|
||||
public class PartiePoisson {
|
||||
|
||||
/**
|
||||
* Nom de la partie du poisson.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Le taux d'infestation de cette partie du poisson.
|
||||
*/
|
||||
private Double infestation;
|
||||
|
||||
/**
|
||||
* Constructeur.
|
||||
* Génère une partie complète.
|
||||
*
|
||||
* @param name Le nom de la partie.
|
||||
* @param infestation Le taux d'infestation de la partie du poisson.
|
||||
*/
|
||||
public PartiePoisson(String name, Double infestation) {
|
||||
this.name = name;
|
||||
this.infestation = infestation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructeur.
|
||||
* Génère une infestation de null comme non communiqué.
|
||||
*
|
||||
* @param name Le nom de la partie.
|
||||
*/
|
||||
public PartiePoisson(String name){
|
||||
this.name = name;
|
||||
this.infestation = null;
|
||||
}
|
||||
|
||||
/*
|
||||
GETTERS / SETTERS
|
||||
*/
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Double getInfestation() {
|
||||
return infestation;
|
||||
}
|
||||
|
||||
public void setInfestation(Double infestation) {
|
||||
this.infestation = infestation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,6 +61,22 @@ public class Poisson{
|
||||
return infestation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter de l'attribut des parties de poisson.
|
||||
* @return Le HashSet des parties de poisson.
|
||||
*/
|
||||
public HashSet<PartiePoisson> getFishParts() {
|
||||
return fishParts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter de l'attribut des parties de poisson.
|
||||
* @param fishParts Un hashset de parties de poisson.
|
||||
*/
|
||||
public void setFishParts(HashSet<PartiePoisson> fishParts) {
|
||||
this.fishParts = fishParts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet d'afficher les informations de notre poisson
|
||||
* @return La string contenant les informations
|
||||
|
||||
Reference in New Issue
Block a user