Author: echatellier Date: 2014-09-26 16:49:54 +0200 (Fri, 26 Sep 2014) New Revision: 4118 Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4118 Log: Use generics Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/TableBlockingLayerUI.java Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java =================================================================== --- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java 2014-09-26 14:17:10 UTC (rev 4117) +++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java 2014-09-26 14:49:54 UTC (rev 4118) @@ -73,7 +73,7 @@ private static Log log = LogFactory.getLog(MetierMonitor.class); protected Set<Metier> forbiddenMetier = new HashSet<Metier>(); - protected Set<MultiKey> forbiddenMetierMonth = new HashSet<MultiKey>(); + protected Set<MultiKey<Object>> forbiddenMetierMonth = new HashSet<>(); protected Map<TimeStep, MatrixND> noActivity = new HashMap<TimeStep, MatrixND>(); /** @@ -102,11 +102,11 @@ * @param month */ public void addforbiddenMetier(Metier metier, Month month) { - forbiddenMetierMonth.add(new MultiKey(metier, month)); + forbiddenMetierMonth.add(new MultiKey<Object>(metier, month)); } public void removeforbiddenMetier(Metier metier, Month month) { - forbiddenMetierMonth.remove(new MultiKey(metier, month)); + forbiddenMetierMonth.remove(new MultiKey<Object>(metier, month)); } public void addforbiddenMetier(Collection<Metier> metiers) { @@ -131,7 +131,7 @@ public boolean isForbidden(Metier metier, Month month) { boolean result = forbiddenMetier.contains(metier); if (!result) { - result = forbiddenMetierMonth.contains(new MultiKey(metier, month)); + result = forbiddenMetierMonth.contains(new MultiKey<Object>(metier, month)); } return result; } @@ -180,25 +180,25 @@ ////////////////////////////////////////////////////////////////////////// /** key <Metier, Month, Month> value: <Licence> */ - protected MultiKeyMap list = new MultiKeyMap(); + protected MultiKeyMap<Object, Licence> list = new MultiKeyMap<>(); - class Licence { + static class Licence { int nbLicences = 0; double proportionMaxTotal = 0; - Map<Month, Double> proportionsMonth = new HashMap<Month, Double>(); + Map<Month, Double> proportionsMonth = new HashMap<>(); } public Licence getLicence(Metier metier, Month month) { Licence result = null; - for (MapIterator i=list.mapIterator(); i.hasNext();) { - MultiKey keys = (MultiKey)i.next(); + for (MapIterator<MultiKey<? extends Object>, Licence> i = list.mapIterator(); i.hasNext();) { + MultiKey<? extends Object> keys = i.next(); Metier metierKey = (Metier)keys.getKey(0); Month firstMonth = (Month)keys.getKey(1); Month lastMonth = (Month)keys.getKey(2); if (metier.equals(metierKey) && firstMonth.compareTo(month) <= 0 && month.compareTo(lastMonth) <= 0) { - result = (Licence)i.getValue(); + result = i.getValue(); break; } } @@ -211,15 +211,13 @@ o.nbLicences = nbLicences; o.proportionMaxTotal = this.computeProportionMaxTotal(metier, nbLicences); - for (Month i=firstMonth; i.compareTo(lastMonth) <= 0; i=i.next()) { + for (Month i = firstMonth; i.compareTo(lastMonth) <= 0; i = i.next()) { o.proportionsMonth.put(i, computeProportionMonth(metier, i)); - } this.list.put(metier, firstMonth, lastMonth, o); - } - else{ + } else { log.warn("il existe deja une licence touchant le metier: " + metier + " sur la periode:"+ firstMonth + "-" + lastMonth); } @@ -293,7 +291,7 @@ try { // FIXME: Cette methode n'existe pas dans L'ECMAScript :( -// strategies = Regle_libUtil.getStrategiesMetier(metier); + // strategies = Regle_libUtil.getStrategiesMetier(metier); // Je l'ai traduit avec ce qui suit TopiaContext tx = metier.getTopiaContext(); List<SetOfVessels> res = null; @@ -301,7 +299,7 @@ res = tx.findAll("select setOfVessels from fr.ifremer.isisfish.entities.EffortDescription where possibleMetiers=?", metier); - for(SetOfVessels sov : res){ + for(SetOfVessels sov : res) { nbBoat = nbBoat + sov.getNumberOfVessels(); } } catch (TopiaException eee) { Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/TableBlockingLayerUI.java =================================================================== --- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/TableBlockingLayerUI.java 2014-09-26 14:17:10 UTC (rev 4117) +++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/TableBlockingLayerUI.java 2014-09-26 14:49:54 UTC (rev 4118) @@ -74,14 +74,14 @@ private static Log log = LogFactory.getLog(TableBlockingLayerUI.class); /** Parent UI. */ - protected InputContentUI parent; + protected InputContentUI<?> parent; /** * Init layer with parent. * * @param parent parent */ - public TableBlockingLayerUI(InputContentUI parent) { + public TableBlockingLayerUI(InputContentUI<?> parent) { this.parent = parent; }