public Object calculate(SeasonalAthlete seasonalAthlete, Predicate p) { DataHandler calc = handler(p); Object obj = calc.calculate(seasonalAthlete); obj = calc.convertToNumber(obj, this.type); return obj; }
public boolean shouldRemove(Data data) { try { Object gamesPlayedGoalie = Sorter.def_goalie_games.calculate(data.seasonalAthlete, predicate); Number gamesPlayedGoalieNumber = gamesPlayedGoalie instanceof Number ? (Number) gamesPlayedGoalie : -1; if (StatCategory.def.equals(currentStatCategory)) { for (int i = 0; i < ATTR_SORTERS.length; i++) { AttributeSorter attrPropSorter = ATTR_SORTERS[i]; if (attrPropSorter == null) continue; if (attrPropSorter.cat != StatCategory.def) continue; if (attrPropSorter.loc == StatLocation.goalie && gamesPlayedGoalieNumber.intValue() <= 0) { continue; } DataHandler dh = new DataHandler(attrPropSorter.sorter, predicate, null); Object o = dh.calculateStats(data.seasonalAthlete); if ((o instanceof Number) && 0 <= ((Number) o).doubleValue()) return false; } } else if (StatCategory.off.equals(currentStatCategory)) { DataHandler dh = new DataHandler(Sorter.off_p, predicate, null); Object o = dh.calculateStats(data.seasonalAthlete); return !(o instanceof Number) || 0 >= ((Number) o).intValue(); } } catch (Exception e) { logger.info("the data filter had an exception {}", e); } return true; }