private Collection<Episode> episodes = new ArrayList<Episode>();
public void checkEpisodes(String string) {
for(Episode episode : this.episodes){
System.out.println(string + this.episodes.contains(episode));
}
}
Why would the above code print false?
I'm using a collection because that's what ormlite allows. I think the issue may be caused by ormlite anyways, because a very similar class has an identical method that prints true.
What I'm trying to do is modify an object returned by:
public Episode findEpisode(int num) {
checkEpisodes("Find: ");
for(Episode episode : this.episodes) {
if(episode.getNumber()==num) {
return episode;
}
}
return null;
}
But modification of that object isn't saved. I'm assuming because it's not contained within the Collection.
My solution, which works but isn't ideal:
public void modifyEpisode(Episode episode) {
checkEpisodes("Modify: ");
for (Iterator<?> it = this.episodes.iterator(); it.hasNext();) {
if (((Episode) it.next()).getNumber()==episode.getNumber()) {
it.remove();
addEpisode(episode.getNumber(), episode.getLink(), episode.getLinkLabel());
}
}
}
If you need to see more of my code, just ask, the project is somewhat involved, but it's hosted on sourceforge and I can post a link to it if necessary.