Remove duplicates in GET /arbitrary/hosted/resources response

This commit is contained in:
CalDescent 2022-01-20 22:34:41 +00:00
parent fcdcc939e6
commit 54af36fb85
2 changed files with 19 additions and 1 deletions

View File

@ -400,8 +400,10 @@ public class ArbitraryResource {
arbitraryResourceInfo.name = transactionData.getName();
arbitraryResourceInfo.service = transactionData.getService();
arbitraryResourceInfo.identifier = transactionData.getIdentifier();
if (!resources.contains(arbitraryResourceInfo)) {
resources.add(arbitraryResourceInfo);
}
}
if (includeStatus != null && includeStatus == true) {
resources = this.addStatusToResources(resources);

View File

@ -4,6 +4,7 @@ import org.qortal.arbitrary.misc.Service;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import java.util.Objects;
@XmlAccessorType(XmlAccessType.FIELD)
public class ArbitraryResourceInfo {
@ -16,4 +17,19 @@ public class ArbitraryResourceInfo {
public ArbitraryResourceInfo() {
}
@Override
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof ArbitraryResourceInfo))
return false;
ArbitraryResourceInfo other = (ArbitraryResourceInfo) o;
return Objects.equals(this.name, other.name) &&
Objects.equals(this.service, other.service) &&
Objects.equals(this.identifier, other.identifier);
}
}