mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-30 17:47:14 -04:00
Make payload classes final, extract Attachment in own class
This commit is contained in:
parent
800013768b
commit
245d41f07d
9 changed files with 69 additions and 65 deletions
|
@ -38,7 +38,7 @@ import java.util.Arrays;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class Dispute implements Serializable {
|
||||
public final class Dispute implements Serializable {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
private static final Logger log = LoggerFactory.getLogger(Dispute.class);
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.google.common.util.concurrent.FutureCallback;
|
|||
import com.google.inject.Inject;
|
||||
import io.bitsquare.app.Log;
|
||||
import io.bitsquare.arbitration.messages.*;
|
||||
import io.bitsquare.arbitration.payload.Attachment;
|
||||
import io.bitsquare.btc.TradeWalletService;
|
||||
import io.bitsquare.btc.WalletService;
|
||||
import io.bitsquare.btc.exceptions.TransactionVerificationException;
|
||||
|
@ -274,7 +275,7 @@ public class DisputeManager {
|
|||
}
|
||||
|
||||
// traders send msg to the arbitrator or arbitrator to 1 trader (trader to trader is not allowed)
|
||||
public DisputeCommunicationMessage sendDisputeDirectMessage(Dispute dispute, String text, ArrayList<DisputeCommunicationMessage.Attachment> attachments) {
|
||||
public DisputeCommunicationMessage sendDisputeDirectMessage(Dispute dispute, String text, ArrayList<Attachment> attachments) {
|
||||
DisputeCommunicationMessage disputeCommunicationMessage = new DisputeCommunicationMessage(dispute.getTradeId(),
|
||||
dispute.getTraderPubKeyRing().hashCode(),
|
||||
isTrader(dispute),
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.io.Serializable;
|
|||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
public class DisputeResult implements Serializable {
|
||||
public final class DisputeResult implements Serializable {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
private static final Logger log = LoggerFactory.getLogger(DisputeResult.class);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package io.bitsquare.arbitration.messages;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.payload.Attachment;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
|
@ -26,9 +27,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -180,58 +179,4 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
|
|||
", attachments=" + attachments +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Static classes
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static class Attachment implements Serializable {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
private static final Logger log = LoggerFactory.getLogger(Attachment.class);
|
||||
|
||||
private final byte[] bytes;
|
||||
private final String fileName;
|
||||
|
||||
public Attachment(String fileName, byte[] bytes) {
|
||||
this.fileName = fileName;
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Attachment)) return false;
|
||||
|
||||
Attachment that = (Attachment) o;
|
||||
|
||||
if (!Arrays.equals(bytes, that.bytes)) return false;
|
||||
return !(fileName != null ? !fileName.equals(that.fileName) : that.fileName != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = bytes != null ? Arrays.hashCode(bytes) : 0;
|
||||
result = 31 * result + (fileName != null ? fileName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Attachment{" +
|
||||
"description=" + fileName +
|
||||
", data=" + Arrays.toString(bytes) +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package io.bitsquare.arbitration.payload;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class Attachment implements Serializable {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
private static final Logger log = LoggerFactory.getLogger(Attachment.class);
|
||||
|
||||
private final byte[] bytes;
|
||||
private final String fileName;
|
||||
|
||||
public Attachment(String fileName, byte[] bytes) {
|
||||
this.fileName = fileName;
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Attachment)) return false;
|
||||
|
||||
Attachment that = (Attachment) o;
|
||||
|
||||
if (!Arrays.equals(bytes, that.bytes)) return false;
|
||||
return !(fileName != null ? !fileName.equals(that.fileName) : that.fileName != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = bytes != null ? Arrays.hashCode(bytes) : 0;
|
||||
result = 31 * result + (fileName != null ? fileName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Attachment{" +
|
||||
"description=" + fileName +
|
||||
", data=" + Arrays.toString(bytes) +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ import io.bitsquare.app.Version;
|
|||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class RawInput implements Serializable {
|
||||
public final class RawInput implements Serializable {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue