2015-10-12 18:25:05 -07:00
|
|
|
package org.thoughtcrime.securesms.attachments;
|
|
|
|
|
2018-04-26 17:03:54 -07:00
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
|
2015-10-12 18:25:05 -07:00
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
|
|
|
|
|
|
|
public class AttachmentId {
|
|
|
|
|
2018-04-26 17:03:54 -07:00
|
|
|
@JsonProperty
|
2015-10-12 18:25:05 -07:00
|
|
|
private final long rowId;
|
2018-04-26 17:03:54 -07:00
|
|
|
|
|
|
|
@JsonProperty
|
2015-10-12 18:25:05 -07:00
|
|
|
private final long uniqueId;
|
|
|
|
|
2018-04-26 17:03:54 -07:00
|
|
|
public AttachmentId(@JsonProperty("rowId") long rowId, @JsonProperty("uniqueId") long uniqueId) {
|
2015-10-12 18:25:05 -07:00
|
|
|
this.rowId = rowId;
|
|
|
|
this.uniqueId = uniqueId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getRowId() {
|
|
|
|
return rowId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getUniqueId() {
|
|
|
|
return uniqueId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String[] toStrings() {
|
|
|
|
return new String[] {String.valueOf(rowId), String.valueOf(uniqueId)};
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
return "(row id: " + rowId + ", unique ID: " + uniqueId + ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isValid() {
|
|
|
|
return rowId >= 0 && uniqueId >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
|
|
|
|
AttachmentId attachmentId = (AttachmentId)o;
|
|
|
|
|
|
|
|
if (rowId != attachmentId.rowId) return false;
|
|
|
|
return uniqueId == attachmentId.uniqueId;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return Util.hashCode(rowId, uniqueId);
|
|
|
|
}
|
|
|
|
}
|