mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Fix nullable problems in DisputeResult
This commit is contained in:
parent
38a86d2e5c
commit
11338f6567
2 changed files with 20 additions and 50 deletions
|
@ -28,6 +28,7 @@ import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bitcoinj.core.Coin;
|
import org.bitcoinj.core.Coin;
|
||||||
|
@ -59,6 +60,7 @@ public final class DisputeResult implements NetworkPayload {
|
||||||
|
|
||||||
private final String tradeId;
|
private final String tradeId;
|
||||||
private final int traderId;
|
private final int traderId;
|
||||||
|
@Setter
|
||||||
@Nullable
|
@Nullable
|
||||||
private Winner winner;
|
private Winner winner;
|
||||||
private int reasonOrdinal = Reason.OTHER.ordinal();
|
private int reasonOrdinal = Reason.OTHER.ordinal();
|
||||||
|
@ -66,12 +68,19 @@ public final class DisputeResult implements NetworkPayload {
|
||||||
private final BooleanProperty idVerificationProperty = new SimpleBooleanProperty();
|
private final BooleanProperty idVerificationProperty = new SimpleBooleanProperty();
|
||||||
private final BooleanProperty screenCastProperty = new SimpleBooleanProperty();
|
private final BooleanProperty screenCastProperty = new SimpleBooleanProperty();
|
||||||
private final StringProperty summaryNotesProperty = new SimpleStringProperty("");
|
private final StringProperty summaryNotesProperty = new SimpleStringProperty("");
|
||||||
|
@Setter
|
||||||
|
@Nullable
|
||||||
private DisputeCommunicationMessage disputeCommunicationMessage;
|
private DisputeCommunicationMessage disputeCommunicationMessage;
|
||||||
|
@Setter
|
||||||
|
@Nullable
|
||||||
private byte[] arbitratorSignature;
|
private byte[] arbitratorSignature;
|
||||||
private long buyerPayoutAmount;
|
private long buyerPayoutAmount;
|
||||||
private long sellerPayoutAmount;
|
private long sellerPayoutAmount;
|
||||||
|
@Setter
|
||||||
|
@Nullable
|
||||||
private byte[] arbitratorPubKey;
|
private byte[] arbitratorPubKey;
|
||||||
private long closeDate;
|
private long closeDate;
|
||||||
|
@Setter
|
||||||
private boolean isLoserPublisher;
|
private boolean isLoserPublisher;
|
||||||
|
|
||||||
public DisputeResult(String tradeId, int traderId) {
|
public DisputeResult(String tradeId, int traderId) {
|
||||||
|
@ -81,17 +90,17 @@ public final class DisputeResult implements NetworkPayload {
|
||||||
|
|
||||||
public DisputeResult(String tradeId,
|
public DisputeResult(String tradeId,
|
||||||
int traderId,
|
int traderId,
|
||||||
Winner winner,
|
@Nullable Winner winner,
|
||||||
int reasonOrdinal,
|
int reasonOrdinal,
|
||||||
boolean tamperProofEvidence,
|
boolean tamperProofEvidence,
|
||||||
boolean idVerification,
|
boolean idVerification,
|
||||||
boolean screenCast,
|
boolean screenCast,
|
||||||
String summaryNotes,
|
String summaryNotes,
|
||||||
DisputeCommunicationMessage disputeCommunicationMessage,
|
@Nullable DisputeCommunicationMessage disputeCommunicationMessage,
|
||||||
byte[] arbitratorSignature,
|
@Nullable byte[] arbitratorSignature,
|
||||||
long buyerPayoutAmount,
|
long buyerPayoutAmount,
|
||||||
long sellerPayoutAmount,
|
long sellerPayoutAmount,
|
||||||
byte[] arbitratorPubKey,
|
@Nullable byte[] arbitratorPubKey,
|
||||||
long closeDate,
|
long closeDate,
|
||||||
boolean isLoserPublisher) {
|
boolean isLoserPublisher) {
|
||||||
this.tradeId = tradeId;
|
this.tradeId = tradeId;
|
||||||
|
@ -125,7 +134,7 @@ public final class DisputeResult implements NetworkPayload {
|
||||||
proto.getIdVerification(),
|
proto.getIdVerification(),
|
||||||
proto.getScreenCast(),
|
proto.getScreenCast(),
|
||||||
proto.getSummaryNotes(),
|
proto.getSummaryNotes(),
|
||||||
DisputeCommunicationMessage.fromPayloadProto(proto.getDisputeCommunicationMessage()),
|
proto.getDisputeCommunicationMessage() == null ? null : DisputeCommunicationMessage.fromPayloadProto(proto.getDisputeCommunicationMessage()),
|
||||||
proto.getArbitratorSignature().toByteArray(),
|
proto.getArbitratorSignature().toByteArray(),
|
||||||
proto.getBuyerPayoutAmount(),
|
proto.getBuyerPayoutAmount(),
|
||||||
proto.getSellerPayoutAmount(),
|
proto.getSellerPayoutAmount(),
|
||||||
|
@ -144,15 +153,16 @@ public final class DisputeResult implements NetworkPayload {
|
||||||
.setIdVerification(idVerificationProperty.get())
|
.setIdVerification(idVerificationProperty.get())
|
||||||
.setScreenCast(screenCastProperty.get())
|
.setScreenCast(screenCastProperty.get())
|
||||||
.setSummaryNotes(summaryNotesProperty.get())
|
.setSummaryNotes(summaryNotesProperty.get())
|
||||||
.setDisputeCommunicationMessage(disputeCommunicationMessage.toProtoNetworkEnvelope().getDisputeCommunicationMessage())
|
|
||||||
.setArbitratorSignature(ByteString.copyFrom(arbitratorSignature))
|
|
||||||
.setBuyerPayoutAmount(buyerPayoutAmount)
|
.setBuyerPayoutAmount(buyerPayoutAmount)
|
||||||
.setSellerPayoutAmount(sellerPayoutAmount)
|
.setSellerPayoutAmount(sellerPayoutAmount)
|
||||||
.setArbitratorPubKey(ByteString.copyFrom(arbitratorPubKey))
|
|
||||||
.setCloseDate(closeDate)
|
.setCloseDate(closeDate)
|
||||||
.setIsLoserPublisher(isLoserPublisher);
|
.setIsLoserPublisher(isLoserPublisher);
|
||||||
|
|
||||||
|
Optional.ofNullable(arbitratorSignature).ifPresent(arbitratorSignature -> builder.setArbitratorSignature(ByteString.copyFrom(arbitratorSignature)));
|
||||||
|
Optional.ofNullable(arbitratorPubKey).ifPresent(arbitratorPubKey -> builder.setArbitratorPubKey(ByteString.copyFrom(arbitratorPubKey)));
|
||||||
Optional.ofNullable(winner).ifPresent(result -> builder.setWinner(PB.DisputeResult.Winner.valueOf(winner.name())));
|
Optional.ofNullable(winner).ifPresent(result -> builder.setWinner(PB.DisputeResult.Winner.valueOf(winner.name())));
|
||||||
|
Optional.ofNullable(disputeCommunicationMessage).ifPresent(disputeCommunicationMessage ->
|
||||||
|
builder.setDisputeCommunicationMessage(disputeCommunicationMessage.toProtoNetworkEnvelope().getDisputeCommunicationMessage()));
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
@ -193,22 +203,6 @@ public final class DisputeResult implements NetworkPayload {
|
||||||
return summaryNotesProperty;
|
return summaryNotesProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisputeCommunicationMessage(DisputeCommunicationMessage disputeCommunicationMessage) {
|
|
||||||
this.disputeCommunicationMessage = disputeCommunicationMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DisputeCommunicationMessage getDisputeCommunicationMessage() {
|
|
||||||
return disputeCommunicationMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArbitratorSignature(byte[] arbitratorSignature) {
|
|
||||||
this.arbitratorSignature = arbitratorSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getArbitratorSignature() {
|
|
||||||
return arbitratorSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBuyerPayoutAmount(Coin buyerPayoutAmount) {
|
public void setBuyerPayoutAmount(Coin buyerPayoutAmount) {
|
||||||
this.buyerPayoutAmount = buyerPayoutAmount.value;
|
this.buyerPayoutAmount = buyerPayoutAmount.value;
|
||||||
}
|
}
|
||||||
|
@ -225,14 +219,6 @@ public final class DisputeResult implements NetworkPayload {
|
||||||
return Coin.valueOf(sellerPayoutAmount);
|
return Coin.valueOf(sellerPayoutAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArbitratorPubKey(byte[] arbitratorPubKey) {
|
|
||||||
this.arbitratorPubKey = arbitratorPubKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getArbitratorPubKey() {
|
|
||||||
return arbitratorPubKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCloseDate(Date closeDate) {
|
public void setCloseDate(Date closeDate) {
|
||||||
this.closeDate = closeDate.getTime();
|
this.closeDate = closeDate.getTime();
|
||||||
}
|
}
|
||||||
|
@ -240,20 +226,4 @@ public final class DisputeResult implements NetworkPayload {
|
||||||
public Date getCloseDate() {
|
public Date getCloseDate() {
|
||||||
return new Date(closeDate);
|
return new Date(closeDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWinner(Winner winner) {
|
|
||||||
this.winner = winner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Winner getWinner() {
|
|
||||||
return winner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoserIsPublisher(boolean loserPublisher) {
|
|
||||||
this.isLoserPublisher = loserPublisher;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLoserPublisher() {
|
|
||||||
return isLoserPublisher;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
|
||||||
disputeResult.setBuyerPayoutAmount(peersDisputeResult.getBuyerPayoutAmount());
|
disputeResult.setBuyerPayoutAmount(peersDisputeResult.getBuyerPayoutAmount());
|
||||||
disputeResult.setSellerPayoutAmount(peersDisputeResult.getSellerPayoutAmount());
|
disputeResult.setSellerPayoutAmount(peersDisputeResult.getSellerPayoutAmount());
|
||||||
disputeResult.setWinner(peersDisputeResult.getWinner());
|
disputeResult.setWinner(peersDisputeResult.getWinner());
|
||||||
disputeResult.setLoserIsPublisher(peersDisputeResult.isLoserPublisher());
|
disputeResult.setLoserPublisher(peersDisputeResult.isLoserPublisher());
|
||||||
disputeResult.setReason(peersDisputeResult.getReason());
|
disputeResult.setReason(peersDisputeResult.getReason());
|
||||||
disputeResult.setSummaryNotes(peersDisputeResult.summaryNotesProperty().get());
|
disputeResult.setSummaryNotes(peersDisputeResult.summaryNotesProperty().get());
|
||||||
|
|
||||||
|
@ -534,7 +534,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
|
||||||
closeTicketButton.disableProperty().unbind();
|
closeTicketButton.disableProperty().unbind();
|
||||||
dispute.setDisputeResult(disputeResult);
|
dispute.setDisputeResult(disputeResult);
|
||||||
|
|
||||||
disputeResult.setLoserIsPublisher(isLoserPublisherCheckBox.isSelected());
|
disputeResult.setLoserPublisher(isLoserPublisherCheckBox.isSelected());
|
||||||
disputeResult.setCloseDate(new Date());
|
disputeResult.setCloseDate(new Date());
|
||||||
String text = Res.get("disputeSummaryWindow.close.msg",
|
String text = Res.get("disputeSummaryWindow.close.msg",
|
||||||
formatter.formatDateTime(disputeResult.getCloseDate()),
|
formatter.formatDateTime(disputeResult.getCloseDate()),
|
||||||
|
|
Loading…
Add table
Reference in a new issue