Make 'fromProto' static methods return most specific type

Minor change for consistency: narrow the signature of some remaining
such methods, which have return type 'PersistableEnvelope'.

(This excludes some other cases with return type 'NetworkEnvelope'.)
This commit is contained in:
Steven Barclay 2020-03-03 21:40:31 +08:00
parent a926f2b260
commit 18f75869a2
No known key found for this signature in database
GPG Key ID: 9FED6BF1176D500B
15 changed files with 20 additions and 26 deletions

View File

@ -45,7 +45,7 @@ public class NavigationPath implements PersistableEnvelope {
return protobuf.PersistableEnvelope.newBuilder().setNavigationPath(builder).build();
}
public static PersistableEnvelope fromProto(protobuf.NavigationPath proto) {
public static NavigationPath fromProto(protobuf.NavigationPath proto) {
return new NavigationPath(new ArrayList<>(proto.getPathList()));
}
}

View File

@ -70,7 +70,7 @@ public class SignedWitnessStore implements PersistableEnvelope {
return protobuf.SignedWitnessStore.newBuilder().addAllItems(protoList);
}
public static PersistableEnvelope fromProto(protobuf.SignedWitnessStore proto) {
public static SignedWitnessStore fromProto(protobuf.SignedWitnessStore proto) {
List<SignedWitness> list = proto.getItemsList().stream()
.map(SignedWitness::fromProto).collect(Collectors.toList());
return new SignedWitnessStore(list);

View File

@ -69,7 +69,7 @@ public class AccountAgeWitnessStore implements PersistableEnvelope {
return protobuf.AccountAgeWitnessStore.newBuilder().addAllItems(protoList);
}
public static PersistableEnvelope fromProto(protobuf.AccountAgeWitnessStore proto) {
public static AccountAgeWitnessStore fromProto(protobuf.AccountAgeWitnessStore proto) {
List<AccountAgeWitness> list = proto.getItemsList().stream()
.map(AccountAgeWitness::fromProto).collect(Collectors.toList());
return new AccountAgeWitnessStore(list);

View File

@ -19,7 +19,6 @@ package bisq.core.dao.governance.blindvote;
import bisq.core.dao.governance.ConsensusCritical;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.proto.persistable.PersistableList;
import com.google.protobuf.Message;
@ -59,7 +58,7 @@ public class MyBlindVoteList extends PersistableList<BlindVote> implements Conse
.build();
}
public static PersistableEnvelope fromProto(protobuf.MyBlindVoteList proto) {
public static MyBlindVoteList fromProto(protobuf.MyBlindVoteList proto) {
return new MyBlindVoteList(new ArrayList<>(proto.getBlindVoteList().stream()
.map(BlindVote::fromProto)
.collect(Collectors.toList())));

View File

@ -69,7 +69,7 @@ public class BlindVoteStore implements PersistableEnvelope {
return protobuf.BlindVoteStore.newBuilder().addAllItems(protoList);
}
public static PersistableEnvelope fromProto(protobuf.BlindVoteStore proto) {
public static BlindVoteStore fromProto(protobuf.BlindVoteStore proto) {
List<BlindVotePayload> list = proto.getItemsList().stream()
.map(BlindVotePayload::fromProto).collect(Collectors.toList());
return new BlindVoteStore(list);

View File

@ -17,7 +17,6 @@
package bisq.core.dao.governance.myvote;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.proto.persistable.PersistableList;
import com.google.protobuf.Message;
@ -31,7 +30,7 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public class MyVoteList extends PersistableList<MyVote> {
public MyVoteList() {
MyVoteList() {
super();
}
@ -53,7 +52,7 @@ public class MyVoteList extends PersistableList<MyVote> {
.build();
}
public static PersistableEnvelope fromProto(protobuf.MyVoteList proto) {
public static MyVoteList fromProto(protobuf.MyVoteList proto) {
return new MyVoteList(new ArrayList<>(proto.getMyVoteList().stream()
.map(MyVote::fromProto)
.collect(Collectors.toList())));

View File

@ -69,7 +69,7 @@ public class ProposalStore implements PersistableEnvelope {
return protobuf.ProposalStore.newBuilder().addAllItems(protoList);
}
public static PersistableEnvelope fromProto(protobuf.ProposalStore proto) {
public static ProposalStore fromProto(protobuf.ProposalStore proto) {
List<ProposalPayload> list = proto.getItemsList().stream()
.map(ProposalPayload::fromProto).collect(Collectors.toList());
return new ProposalStore(list);

View File

@ -72,7 +72,7 @@ public class TempProposalStore implements PersistableEnvelope {
return protobuf.TempProposalStore.newBuilder().addAllItems(protoList);
}
public static PersistableEnvelope fromProto(protobuf.TempProposalStore proto, NetworkProtoResolver networkProtoResolver) {
public static TempProposalStore fromProto(protobuf.TempProposalStore proto, NetworkProtoResolver networkProtoResolver) {
List<ProtectedStorageEntry> list = proto.getItemsList().stream()
.map(entry -> ProtectedStorageEntry.fromProto(entry, networkProtoResolver))
.collect(Collectors.toList());

View File

@ -67,7 +67,7 @@ public class DaoStateStore implements PersistableEnvelope {
.build();
}
public static PersistableEnvelope fromProto(protobuf.DaoStateStore proto) {
public static DaoStateStore fromProto(protobuf.DaoStateStore proto) {
LinkedList<DaoStateHash> daoStateHashList = proto.getDaoStateHashList().isEmpty() ?
new LinkedList<>() :
new LinkedList<>(proto.getDaoStateHashList().stream()

View File

@ -17,7 +17,6 @@
package bisq.core.dao.state.unconfirmed;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.proto.persistable.PersistableList;
import com.google.protobuf.Message;
@ -52,7 +51,7 @@ public class UnconfirmedBsqChangeOutputList extends PersistableList<UnconfirmedT
.build();
}
public static PersistableEnvelope fromProto(protobuf.UnconfirmedBsqChangeOutputList proto) {
public static UnconfirmedBsqChangeOutputList fromProto(protobuf.UnconfirmedBsqChangeOutputList proto) {
return new UnconfirmedBsqChangeOutputList(new ArrayList<>(proto.getUnconfirmedTxOutputList().stream()
.map(UnconfirmedTxOutput::fromProto)
.collect(Collectors.toList())));

View File

@ -19,7 +19,6 @@ package bisq.core.payment;
import bisq.core.proto.CoreProtoResolver;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.proto.persistable.PersistableList;
import com.google.protobuf.Message;
@ -45,7 +44,7 @@ public class PaymentAccountList extends PersistableList<PaymentAccount> {
.build();
}
public static PersistableEnvelope fromProto(protobuf.PaymentAccountList proto, CoreProtoResolver coreProtoResolver) {
public static PaymentAccountList fromProto(protobuf.PaymentAccountList proto, CoreProtoResolver coreProtoResolver) {
return new PaymentAccountList(new ArrayList<>(proto.getPaymentAccountList().stream()
.map(e -> PaymentAccount.fromProto(e, coreProtoResolver))
.collect(Collectors.toList())));

View File

@ -68,7 +68,7 @@ public class TradeStatistics2Store implements PersistableEnvelope {
return protobuf.TradeStatistics2Store.newBuilder().addAllItems(protoList);
}
public static PersistableEnvelope fromProto(protobuf.TradeStatistics2Store proto) {
public static TradeStatistics2Store fromProto(protobuf.TradeStatistics2Store proto) {
List<TradeStatistics2> list = proto.getItemsList().stream()
.map(TradeStatistics2::fromProto).collect(Collectors.toList());
return new TradeStatistics2Store(list);

View File

@ -132,7 +132,7 @@ public final class PreferencesPayload implements PersistableEnvelope {
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
public PreferencesPayload() {
PreferencesPayload() {
}
@ -207,7 +207,7 @@ public final class PreferencesPayload implements PersistableEnvelope {
return protobuf.PersistableEnvelope.newBuilder().setPreferencesPayload(builder).build();
}
public static PersistableEnvelope fromProto(protobuf.PreferencesPayload proto, CoreProtoResolver coreProtoResolver) {
public static PreferencesPayload fromProto(protobuf.PreferencesPayload proto, CoreProtoResolver coreProtoResolver) {
final protobuf.Country userCountry = proto.getUserCountry();
PaymentAccount paymentAccount = null;
if (proto.hasSelectedPaymentAccountForCreateOffer() && proto.getSelectedPaymentAccountForCreateOffer().hasPaymentMethod())
@ -275,6 +275,5 @@ public final class PreferencesPayload implements PersistableEnvelope {
proto.getBuyerSecurityDepositAsPercentForCrypto(),
proto.getBlockNotifyPort(),
proto.getTacAcceptedV120());
}
}

View File

@ -17,7 +17,6 @@
package bisq.network.p2p.peers.peerexchange;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.proto.persistable.PersistableList;
import com.google.protobuf.Message;
@ -43,7 +42,7 @@ public class PeerList extends PersistableList<Peer> {
.build();
}
public static PersistableEnvelope fromProto(protobuf.PeerList proto) {
public static PeerList fromProto(protobuf.PeerList proto) {
return new PeerList(new ArrayList<>(proto.getPeerList().stream()
.map(Peer::fromProto)
.collect(Collectors.toList())));

View File

@ -46,7 +46,7 @@ public class PersistableNetworkPayloadList implements PersistableEnvelope {
@Getter
private Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map = new ConcurrentHashMap<>();
public PersistableNetworkPayloadList() {
PersistableNetworkPayloadList() {
}
@ -54,7 +54,7 @@ public class PersistableNetworkPayloadList implements PersistableEnvelope {
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////
public PersistableNetworkPayloadList(Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map) {
private PersistableNetworkPayloadList(Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map) {
this.map.putAll(map);
}
@ -69,8 +69,8 @@ public class PersistableNetworkPayloadList implements PersistableEnvelope {
.build();
}
public static PersistableEnvelope fromProto(protobuf.PersistableNetworkPayloadList proto,
PersistenceProtoResolver resolver) {
public static PersistableNetworkPayloadList fromProto(protobuf.PersistableNetworkPayloadList proto,
PersistenceProtoResolver resolver) {
Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map = new HashMap<>();
proto.getItemsList()
.forEach(e -> {