mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Refactor
Use a stream filter instead of a if clause
This commit is contained in:
parent
cafbbdf94c
commit
00fe80ef0e
@ -200,18 +200,19 @@ public class MultipleHolderNameDetection {
|
|||||||
|
|
||||||
private Map<String, List<Dispute>> getAllDisputesByTraderMap() {
|
private Map<String, List<Dispute>> getAllDisputesByTraderMap() {
|
||||||
Map<String, List<Dispute>> allDisputesByTraderMap = new HashMap<>();
|
Map<String, List<Dispute>> allDisputesByTraderMap = new HashMap<>();
|
||||||
disputeManager.getDisputesAsObservableList()
|
disputeManager.getDisputesAsObservableList().stream()
|
||||||
.forEach(dispute -> {
|
.filter(dispute -> {
|
||||||
Contract contract = dispute.getContract();
|
Contract contract = dispute.getContract();
|
||||||
PaymentAccountPayload paymentAccountPayload = isBuyer(dispute) ?
|
PaymentAccountPayload paymentAccountPayload = isBuyer(dispute) ?
|
||||||
contract.getBuyerPaymentAccountPayload() :
|
contract.getBuyerPaymentAccountPayload() :
|
||||||
contract.getSellerPaymentAccountPayload();
|
contract.getSellerPaymentAccountPayload();
|
||||||
if (paymentAccountPayload instanceof PayloadWithHolderName) {
|
return paymentAccountPayload instanceof PayloadWithHolderName;
|
||||||
String traderPubKeyHash = getSigPubKeyHashAsHex(dispute);
|
})
|
||||||
allDisputesByTraderMap.putIfAbsent(traderPubKeyHash, new ArrayList<>());
|
.forEach(dispute -> {
|
||||||
List<Dispute> disputes = allDisputesByTraderMap.get(traderPubKeyHash);
|
String traderPubKeyHash = getSigPubKeyHashAsHex(dispute);
|
||||||
disputes.add(dispute);
|
allDisputesByTraderMap.putIfAbsent(traderPubKeyHash, new ArrayList<>());
|
||||||
}
|
List<Dispute> disputes = allDisputesByTraderMap.get(traderPubKeyHash);
|
||||||
|
disputes.add(dispute);
|
||||||
});
|
});
|
||||||
return allDisputesByTraderMap;
|
return allDisputesByTraderMap;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user