Implement missing equals and hashcode methods for feeditem (#7132)
Till 5713b1826795598848c95f31df906b7af5ce7076 many classes like FeedItem used to inherit from FeedComponent which provided those two methods. However since that commit the component no longer exists and now the classes need to implement it on their own. Without this, ArrayList.remove breaks.
This commit is contained in:
parent
0aa8e85003
commit
4bc0b38280
@ -1,6 +1,7 @@
|
|||||||
package de.danoeh.antennapod.model.feed;
|
package de.danoeh.antennapod.model.feed;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Chapter {
|
public class Chapter {
|
||||||
private long id;
|
private long id;
|
||||||
@ -88,4 +89,22 @@ public class Chapter {
|
|||||||
}
|
}
|
||||||
return chapters.size() - 1;
|
return chapters.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Chapter chapter = (Chapter) o;
|
||||||
|
return id == chapter.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import androidx.annotation.Nullable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -468,4 +470,22 @@ public class Feed {
|
|||||||
public boolean isLocalFeed() {
|
public boolean isLocalFeed() {
|
||||||
return downloadUrl.startsWith(PREFIX_LOCAL_FOLDER);
|
return downloadUrl.startsWith(PREFIX_LOCAL_FOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Feed feed = (Feed) o;
|
||||||
|
return id == feed.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import java.io.Serializable;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -418,4 +419,22 @@ public class FeedItem implements Serializable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FeedItem feedItem = (FeedItem) o;
|
||||||
|
return id == feedItem.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -501,12 +501,21 @@ public class FeedMedia implements Playable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (o instanceof RemoteMedia) {
|
if (o instanceof RemoteMedia) {
|
||||||
return o.equals(this);
|
return o.equals(this);
|
||||||
}
|
}
|
||||||
return super.equals(o);
|
|
||||||
|
if (getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FeedMedia feedMedia = (FeedMedia) o;
|
||||||
|
return id == feedMedia.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user