Remove unneeded interface, cleanup interfaces

This commit is contained in:
Manfred Karrer 2017-05-11 23:11:10 +02:00
parent e8d2b54d3e
commit 4e824e6cf4
8 changed files with 12 additions and 14 deletions

View File

@ -18,9 +18,13 @@
package io.bisq.common;
import com.google.protobuf.Message;
import org.apache.commons.lang3.NotImplementedException;
import java.io.Serializable;
public interface Marshaller extends Serializable {
Message toProto();
//TODO
default Message toProto() {
throw new NotImplementedException("toProtobuf not yet implemented.");
}
}

View File

@ -13,5 +13,4 @@ public interface Msg extends Marshaller {
int getMessageVersion();
PB.Envelope toEnvelopeProto();
}

View File

@ -18,7 +18,6 @@
package io.bisq.common.persistence;
import com.google.protobuf.Message;
import io.bisq.common.Marshaller;
import lombok.Getter;
import lombok.Setter;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -29,7 +28,7 @@ import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
public class ListPersistable<T extends Marshaller> implements Persistable {
public class ListPersistable<T extends Persistable> implements Persistable {
@Getter
@Setter
private List<T> list;

View File

@ -6,6 +6,7 @@ import io.bisq.common.persistence.Persistable;
* Used to wrap a plaintext string to distinguish at file storage and safe it as plain text instead of a serialized java object.
*/
// We would not need Persistable but as it is used in Storage and Storage expects a Persistable as type we keep it...
// TODO use same like in the BSQChainState JSON persistence....
public class PlainTextWrapper implements Persistable {
// That object is not saved to disc it is only of type Serializable to support the persistent framework.
// SerialVersionUID has no relevance here.

View File

@ -2,7 +2,6 @@ package io.bisq.network.p2p.peers.getdata.messages;
import com.google.protobuf.ByteString;
import com.google.protobuf.Message;
import io.bisq.common.Marshaller;
import io.bisq.common.app.Capabilities;
import io.bisq.common.app.Version;
import io.bisq.common.network.Msg;
@ -15,7 +14,7 @@ import java.util.ArrayList;
import java.util.Set;
import java.util.stream.Collectors;
public final class PreliminaryGetDataRequest implements AnonymousMsg, GetDataRequest, SupportedCapabilitiesMsg, Marshaller {
public final class PreliminaryGetDataRequest implements AnonymousMsg, GetDataRequest, SupportedCapabilitiesMsg {
// 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;

View File

@ -1,6 +1,5 @@
package io.bisq.network.p2p.peers.peerexchange.messages;
import io.bisq.common.Marshaller;
import io.bisq.common.app.Capabilities;
import io.bisq.common.app.Version;
import io.bisq.common.network.Msg;
@ -17,7 +16,7 @@ import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkNotNull;
public final class GetPeersRequest extends PeerExchangeMsg implements SendersNodeAddressMsg, SupportedCapabilitiesMsg, Marshaller {
public final class GetPeersRequest extends PeerExchangeMsg implements SendersNodeAddressMsg, SupportedCapabilitiesMsg {
// 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;

View File

@ -3,7 +3,7 @@ package io.bisq.network.p2p.storage;
import com.google.common.annotations.VisibleForTesting;
import com.google.protobuf.ByteString;
import com.google.protobuf.Message;
import io.bisq.common.Marshaller;
import io.bisq.common.Payload;
import io.bisq.common.Timer;
import io.bisq.common.UserThread;
import io.bisq.common.app.Log;
@ -38,7 +38,6 @@ import org.spongycastle.util.encoders.Hex;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Paths;
import java.security.KeyPair;
import java.security.PublicKey;
@ -681,13 +680,12 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
// Static class
///////////////////////////////////////////////////////////////////////////////////////////
/**
* Used as container for calculating cryptographic hash of data and sequenceNumber.
* Needs to be Serializable because we convert the object to a byte array via java serialization
* before calculating the hash.
*/
public static final class DataAndSeqNrPair implements Serializable, Marshaller {
public static final class DataAndSeqNrPair implements Payload {
// data are only used for calculating cryptographic hash from both values so they are kept private
private final StoragePayload data;
private final int sequenceNumber;

View File

@ -2,14 +2,13 @@ package io.bisq.network.p2p.storage.messages;
import com.google.protobuf.ByteString;
import com.google.protobuf.Message;
import io.bisq.common.Marshaller;
import io.bisq.common.app.Version;
import io.bisq.common.network.Msg;
import io.bisq.generated.protobuffer.PB;
import java.util.Arrays;
public final class RefreshTTLMsg extends BroadcastMsg implements Marshaller {
public final class RefreshTTLMsg extends BroadcastMsg {
// 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;