@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof PokemonData)) return false; PokemonData pkm = (PokemonData) o; return this.hashCode() == pkm.hashCode(); }
public static PokemonData create( int id, String name, int baseHp, int baseAtt, int baseDef, int baseSpecialAtt, int baseSpecialDef, int baseSpeed, ExperienceCalculator expCalc) { if (POKEDEX.containsKey(id)) { PokemonData cachedPkm = POKEDEX.get(id).get(); if (cachedPkm != null) { return cachedPkm; } } PokemonData pkm = new PokemonData( id, name, baseHp, baseAtt, baseDef, baseSpecialAtt, baseSpecialDef, baseSpeed, expCalc); POKEDEX.put(pkm.getId(), new WeakReference<>(pkm)); return pkm; }
private Object readResolve() { return PokemonData.create( id, name, baseHp, baseAtt, baseDef, baseSpecialAtt, baseSpecialDef, baseSpeed, expCalc); }