diff --git a/duniter4j-core-client/pom.xml b/duniter4j-core-client/pom.xml index 99e76eeb1ea1e7874368e077f2b6ea8c9831f6d0..2c3963dbb4825b0b6823645bc6c2ba1859d78690 100644 --- a/duniter4j-core-client/pom.xml +++ b/duniter4j-core-client/pom.xml @@ -23,12 +23,6 @@ </properties> <dependencies> - <!-- Compile --> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </dependency> - <dependency> <groupId>org.duniter</groupId> <artifactId>duniter4j-core-shared</artifactId> @@ -90,6 +84,12 @@ <artifactId>jackson-databind</artifactId> </dependency> + <!-- Compile --> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </dependency> + <!-- Unit test --> <dependency> <groupId>junit</groupId> diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/config/Configuration.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/config/Configuration.java index d98646f498a1846ea0202e36fbbc332a9d4b90ed..a5b949aaea2a9e257243d5198d0bd562c5012617 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/config/Configuration.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/config/Configuration.java @@ -32,8 +32,6 @@ import org.nuiton.config.ApplicationConfigProvider; import org.nuiton.config.ArgumentsParserException; import org.nuiton.version.Version; import org.nuiton.version.VersionBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.File; import java.net.MalformedURLException; @@ -280,25 +278,25 @@ public class Configuration { return applicationConfig.getOptionAsInt(ConfigurationOption.NETWORK_PEER_UP_MAX_AGE.getKey()); } - public String getNodeElasticSearchHost() { - return applicationConfig.getOption(ConfigurationOption.NODE_ELASTICSEARCH_HOST.getKey()); + public String getCesiumPlusPodHost() { + return applicationConfig.getOption(ConfigurationOption.CESIUM_PLUS_POD_HOST.getKey()); } - public int getNodeElasticSearchPort() { - return applicationConfig.getOptionAsInt(ConfigurationOption.NODE_ELASTICSEARCH_PORT.getKey()); + public int getCesiumPlusPodPort() { + return applicationConfig.getOptionAsInt(ConfigurationOption.CESIUM_PLUS_POD_PORT.getKey()); } - public URL getNodeElasticSearchUrl() { + public URL getCesiumPlusPodUrl() { // Force SSL for 443 port - if (getNodeElasticSearchPort() == 443) { + if (getCesiumPlusPodPort() == 443) { try { - return new URL(applicationConfig.getOption(ConfigurationOption.NODE_ELASTICSEARCH_URL.getKey()) + return new URL(applicationConfig.getOption(ConfigurationOption.CESIUM_PLUS_POD_URL.getKey()) .replaceAll("http://", "https://")); } catch(MalformedURLException e) { - return applicationConfig.getOptionAsURL(ConfigurationOption.NODE_ELASTICSEARCH_URL.getKey()); + return applicationConfig.getOptionAsURL(ConfigurationOption.CESIUM_PLUS_POD_URL.getKey()); } } else { - return applicationConfig.getOptionAsURL(ConfigurationOption.NODE_ELASTICSEARCH_URL.getKey()); + return applicationConfig.getOptionAsURL(ConfigurationOption.CESIUM_PLUS_POD_URL.getKey()); } } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/config/ConfigurationOption.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/config/ConfigurationOption.java index ea5d6ef0c1796491c27a6047175b9848bbc41aa3..3820fca1ef37718cca0d8410aef30e81047b66a1 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/config/ConfigurationOption.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/config/ConfigurationOption.java @@ -196,28 +196,28 @@ public enum ConfigurationOption implements ConfigOptionDef { Integer.class, false), - NODE_ELASTICSEARCH_PROTOCOL( + CESIUM_PLUS_POD_PROTOCOL( "duniter4j.node.elasticsearch.protocol", n("duniter4j.config.option.node.elasticsearch.protocol.description"), "http", String.class, false), - NODE_ELASTICSEARCH_HOST( + CESIUM_PLUS_POD_HOST( "duniter4j.node.elasticsearch.host", n("duniter4j.config.option.node.elasticsearch.host.description"), "localhost", String.class, false), - NODE_ELASTICSEARCH_PORT( + CESIUM_PLUS_POD_PORT( "duniter4j.node.elasticsearch.port", n("duniter4j.config.option.node.elasticsearch.port.description"), "9200", Integer.class, false), - NODE_ELASTICSEARCH_URL( + CESIUM_PLUS_POD_URL( "duniter4j.node.elasticsearch.url", n("duniter4j.config.option.node.elasticsearch.url.description"), "${duniter4j.node.elasticsearch.protocol}://${duniter4j.node.elasticsearch.host}:${duniter4j.node.elasticsearch.port}", diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/example/Example1.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/example/Example1.java index f3f4331617a63a285047304733af21a66db5b6d9..220c23664e7d1b872794b255869ab56a6b96613f 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/example/Example1.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/example/Example1.java @@ -47,7 +47,10 @@ public class Example1 { .build(); // Do something fun ! - BlockchainBlock currentBlock = ServiceLocator.instance().getBlockchainRemoteService().getCurrentBlock(aPeer); + BlockchainBlock currentBlock = ServiceLocator.instance() + .getBlockchainRemoteService() + .getCurrentBlock(aPeer); + System.out.println(String.format("Hello %s world !", currentBlock.getCurrency())); } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/Account.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/Account.java index 002b21117bbfe030b5d195f0755e73ce9f21485b..2607e3d053f4ca06d4fe67d054fdafc59629cd4e 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/Account.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/Account.java @@ -23,11 +23,15 @@ package org.duniter.core.client.model; */ +import lombok.Data; +import lombok.experimental.FieldNameConstants; import org.duniter.core.model.IEntity; /** * Created by eis on 07/02/15. */ +@Data +@FieldNameConstants public class Account implements IEntity<Long> { private Long id; @@ -36,46 +40,4 @@ public class Account implements IEntity<Long> { private String salt; private String cryptPin; - @Override - public Long getId() { - return id; - } - - @Override - public void setId(Long id) { - this.id = id; - } - - - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public String getSalt() { - return salt; - } - - public void setSalt(String salt) { - this.salt = salt; - } - - public String getCryptPin() { - return cryptPin; - } - - public void setCryptPin(String cryptPin) { - this.cryptPin = cryptPin; - } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/BaseIdentity.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/BaseIdentity.java index a6f06b86f059e9c2ee8d2fe97b17e3213188c577..7d3904097b25530f26fb187d94bc5f5557258218 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/BaseIdentity.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/BaseIdentity.java @@ -24,6 +24,10 @@ package org.duniter.core.client.model; import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AccessLevel; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.FieldNameConstants; import java.io.Serializable; @@ -34,13 +38,14 @@ import java.io.Serializable; * @since 1.0 * */ +@Data +@FieldNameConstants public abstract class BaseIdentity implements Serializable { private static final long serialVersionUID = 8080689271400316984L; - public static final String PROPERTY_UID = "uid"; - public static final String PROPERTY_PUBKEY = "pubkey"; - public static final String PROPERTY_SIGNATURE = "signature"; + @NoArgsConstructor(access = AccessLevel.PROTECTED) + public static class Fields {} private String pubkey; @@ -48,22 +53,6 @@ public abstract class BaseIdentity implements Serializable { private String uid; - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; - } - @JsonIgnore @Deprecated public String getSelf() { @@ -76,14 +65,6 @@ public abstract class BaseIdentity implements Serializable { this.signature = signature; } - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - @Override public String toString() { StringBuilder sb = new StringBuilder() diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/TxOutput.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/TxOutput.java index f363fbd62c4b304d2f0b71c936b151b44206ac2b..38c4ecf075c48a2d2c42ddaf506f4871e44bb1f7 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/TxOutput.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/TxOutput.java @@ -23,8 +23,13 @@ package org.duniter.core.client.model; */ +import lombok.Data; +import lombok.experimental.FieldNameConstants; + import java.io.Serializable; +@Data +@FieldNameConstants public class TxOutput implements Serializable { private static final long serialVersionUID = 8084087351543574142L; @@ -35,27 +40,4 @@ public class TxOutput implements Serializable { private int base; - public String getPubKey() { - return pubKey; - } - - public void setPubKey(String pubKey) { - this.pubKey = pubKey; - } - - public long getAmount() { - return amount; - } - - public void setAmount(long amount) { - this.amount = amount; - } - - public int getBase() { - return base; - } - - public void setBase(int base) { - this.base = base; - } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainBlock.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainBlock.java index e4871cd0be986234f9a0cf88268bffccd7ea7de9..d27f54a559be20dfd56fe42338d12e35418722d0 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainBlock.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainBlock.java @@ -72,7 +72,7 @@ public class BlockchainBlock implements Serializable { private String previousHash; private String previousIssuer; private String innerHash; - private Long dividend; + private BigInteger dividend; private Identity[] identities; private Joiner[] joiners; private Joiner[] leavers; diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainDifficulties.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainDifficulties.java index 66ee5a2397f3dc5096f24032eb1c5b234c69c130..9b90a67aeb8098c9c14f196f4eb064d1f62cb43a 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainDifficulties.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainDifficulties.java @@ -23,6 +23,8 @@ package org.duniter.core.client.model.bma; */ import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import lombok.experimental.FieldNameConstants; import org.apache.commons.lang3.ArrayUtils; import java.io.Serializable; @@ -30,46 +32,21 @@ import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; +@Data +@FieldNameConstants public class BlockchainDifficulties implements Serializable { private static final long serialVersionUID = -5631089862715942431L; private Long block; private DifficultyLevel[] levels; - public Long getBlock() { - return block; - } - public void setBlock(Long block) { - this.block = block; - } - public DifficultyLevel[] getLevels() { - return levels; - } - public void setLevels(DifficultyLevel[] levels) { - this.levels = levels; - } - + @Data + @FieldNameConstants public static class DifficultyLevel implements Serializable { private static final long serialVersionUID = 1L; private String uid; private int level; - - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - - public int getLevel() { - return level; - } - - public void setLevel(int level) { - this.level = level; - } } @JsonIgnore diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainMemberships.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainMemberships.java index e200d19c908bd3187971508e94ce5058bfb91b92..18bf931e082d13d88f2b632bdb18674116be3b3d 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainMemberships.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainMemberships.java @@ -22,29 +22,22 @@ package org.duniter.core.client.model.bma; * #L% */ +import lombok.Data; +import lombok.experimental.FieldNameConstants; import org.duniter.core.client.model.BaseIdentity; import java.io.Serializable; +@Data +@FieldNameConstants public class BlockchainMemberships extends BaseIdentity { private static final long serialVersionUID = -5631089862725952431L; private long sigDate; private Membership[] memberships; - public long getSigDate() { - return sigDate; - } - public void setSigDate(long sigDate) { - this.sigDate = sigDate; - } - public Membership[] getMemberships() { - return memberships; - } - public void setMemberships(Membership[] memberships) { - this.memberships = memberships; - } - + @Data + @FieldNameConstants public static class Membership implements Serializable { private static final long serialVersionUID = 1L; @@ -54,35 +47,5 @@ public class BlockchainMemberships extends BaseIdentity { private long blockNumber; private String blockHash; - public String getVersion() { - return version; - } - public void setVersion(String version) { - this.version = version; - } - public String getCurrency() { - return currency; - } - public void setCurrency(String currency) { - this.currency = currency; - } - public String getMembership() { - return membership; - } - public void setMembership(String membership) { - this.membership = membership; - } - public long getBlockNumber() { - return blockNumber; - } - public void setBlockNumber(long blockNumber) { - this.blockNumber = blockNumber; - } - public String getBlockHash() { - return blockHash; - } - public void setBlockHash(String blockHash) { - this.blockHash = blockHash; - } } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainParameters.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainParameters.java index b7386add121d123fad5bc0713be1c519fd728e70..8b643bcb1b7b8786619f0a8214aadd061f2dd691 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainParameters.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainParameters.java @@ -24,15 +24,19 @@ package org.duniter.core.client.model.bma; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.experimental.FieldNameConstants; import java.io.Serializable; /** - * Blockwhain parameters. + * Blockchain parameters. * * @author Benoit Lavenier <benoit.lavenier@e-is.pro> * @since 1.0 */ +@Data +@FieldNameConstants // FIXME: next ignore is due to issue on Duniter v1.4 - should be removed later @JsonIgnoreProperties(ignoreUnknown=true) public class BlockchainParameters implements Serializable{ @@ -147,119 +151,6 @@ public class BlockchainParameters implements Serializable{ */ private Double percentRot; - public String getCurrency() { - return currency; - } - - public void setCurrency(String currency) { - this.currency = currency; - } - - public Double getC() { - return c; - } - - public void setC(Double c) { - this.c = c; - } - - public Integer getDt() { - return dt; - } - - public void setDt(Integer dt) { - this.dt = dt; - } - - public Long getUdTime0() { - return udTime0; - } - - public void setUdTime0(Long udTime0) { - this.udTime0 = udTime0; - } - - public Long getUd0() { - return ud0; - } - - public void setUd0(Long ud0) { - this.ud0 = ud0; - } - - public Long getUdReevalTime0() { - return udReevalTime0; - } - - public void setUdReevalTime0(Long udReevalTime0) { - this.udReevalTime0 = udReevalTime0; - } - - public Long getDtReeval() { - return dtReeval; - } - - public void setDtReeval(Long dtReeval) { - this.dtReeval = dtReeval; - } - - public Integer getSigValidity() { - return sigValidity; - } - - public void setSigValidity(Integer sigValidity) { - this.sigValidity = sigValidity; - } - - public Integer getSigQty() { - return sigQty; - } - - public void setSigQty(Integer sigQty) { - this.sigQty = sigQty; - } - - - public Integer getMsValidity() { - return msValidity; - } - - public void setMsValidity(Integer msValidity) { - this.msValidity = msValidity; - } - - public Integer getStepMax() { - return stepMax; - } - - public void setStepMax(Integer stepMax) { - this.stepMax = stepMax; - } - - public Integer getMedianTimeBlocks() { - return medianTimeBlocks; - } - - public void setMedianTimeBlocks(Integer medianTimeBlocks) { - this.medianTimeBlocks = medianTimeBlocks; - } - - public Integer getAvgGenTime() { - return avgGenTime; - } - - public void setAvgGenTime(Integer avgGenTime) { - this.avgGenTime = avgGenTime; - } - - public Integer getDtDiffEval() { - return dtDiffEval; - } - - public void setDtDiffEval(Integer dtDiffEval) { - this.dtDiffEval = dtDiffEval; - } - @Deprecated public Integer getBlocksRot() { return blocksRot; @@ -270,54 +161,6 @@ public class BlockchainParameters implements Serializable{ this.blocksRot = blocksRot; } - public Double getPercentRot() { - return percentRot; - } - - public void setPercentRot(Double percentRot) { - this.percentRot = percentRot; - } - - public Integer getSigPeriod() { - return sigPeriod; - } - - public void setSigPeriod(Integer sigPeriod) { - this.sigPeriod = sigPeriod; - } - - public Integer getSigStock() { - return sigStock; - } - - public void setSigStock(Integer sigStock) { - this.sigStock = sigStock; - } - - public Integer getSigWindow() { - return sigWindow; - } - - public void setSigWindow(Integer sigWindow) { - this.sigWindow = sigWindow; - } - - public Integer getIdtyWindow() { - return idtyWindow; - } - - public void setIdtyWindow(Integer idtyWindow) { - this.idtyWindow = idtyWindow; - } - - public Integer getMsWindow() { - return msWindow; - } - - public void setMsWindow(Integer msWindow) { - this.msWindow = msWindow; - } - @Override public String toString() { return new StringBuilder() diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/NetworkPeering.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/NetworkPeering.java index b4be598abc5f7a29e1d799ba887c54d8d1752422..6e87fa1eaa5ca6af4f6987ac8754661501b4972b 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/NetworkPeering.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/NetworkPeering.java @@ -23,6 +23,8 @@ package org.duniter.core.client.model.bma; */ import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import lombok.experimental.FieldNameConstants; import org.duniter.core.util.CollectionUtils; import org.duniter.core.util.Preconditions; import org.duniter.core.util.StringUtils; @@ -35,6 +37,8 @@ import java.util.stream.Stream; /** * Created by eis on 05/02/15. */ +@Data +@FieldNameConstants public class NetworkPeering implements Serializable { private Integer version; private String currency; @@ -47,74 +51,6 @@ public class NetworkPeering implements Serializable { public Endpoint[] endpoints; - public Integer getVersion() { - return version; - } - - public void setVersion(Integer version) { - this.version = version; - } - - public String getCurrency() { - return currency; - } - - public void setCurrency(String currency) { - this.currency = currency; - } - - public String getBlock() { - return block; - } - - public void setBlock(String block) { - this.block = block; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; - } - - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - /** - * Unsigned peering document - * @return - */ - public String getRaw() { - return raw; - } - - public void setRaw(String raw) { - this.raw = raw; - } - - public Endpoint[] getEndpoints() { - return endpoints; - } - - public void setEndpoints(Endpoint[] endpoints) { - this.endpoints = endpoints; - } - public String toString() { // Use raw, if exists String raw = this.raw != null ? this.raw : toUnsignedRaw(); @@ -161,6 +97,8 @@ public class NetworkPeering implements Serializable { .toString(); } + @Data + @FieldNameConstants public static class Endpoint implements Serializable { public String api; public String dns; @@ -172,80 +110,6 @@ public class NetworkPeering implements Serializable { public Boolean useSsl; public String raw; - public String getApi() { - return api; - } - - public void setApi(String api) { - this.api = api; - } - - public String getDns() { - return dns; - } - - public void setDns(String dns) { - this.dns = dns; - } - - public String getIpv4() { - return ipv4; - } - - public void setIpv4(String ipv4) { - this.ipv4 = ipv4; - } - - public String getIpv6() { - return ipv6; - } - - public void setIpv6(String ipv6) { - this.ipv6 = ipv6; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public Boolean useSsl() { - return useSsl; - } - - public void setUseSsl(Boolean useSsl) { - this.useSsl = useSsl; - } - - @JsonIgnore - public String getRaw() { - return raw; - } - - @JsonIgnore - public void setRaw(String raw) { - this.raw = raw; - } - @Override public String toString() { if (raw != null) return raw; diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/NetworkPeers.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/NetworkPeers.java index 94b6d1c6b9ea7c18d1cb6d4e41cb6c8b0919d425..0ea639975c5145f63a0a1e79c5b3a8485af01088 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/NetworkPeers.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/NetworkPeers.java @@ -26,12 +26,16 @@ import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonSetter; import com.google.common.base.Joiner; +import lombok.Data; +import lombok.experimental.FieldNameConstants; import java.io.Serializable; /** * Created by eis on 05/02/15. */ +@Data +@FieldNameConstants public class NetworkPeers implements Serializable { public Peer[] peers; @@ -40,42 +44,38 @@ public class NetworkPeers implements Serializable { return Joiner.on(",").join(peers); } + @Data + @FieldNameConstants public static class Peer extends NetworkPeering implements Serializable { + + public interface JsonFields { + String FIRST_DOWN = "first_down"; + String LAST_TRY = "last_try"; + } public Long firstDown; public Long lastTry; - public Long lastContact; public String hash; - @JsonGetter("first_down") + @JsonGetter(JsonFields.FIRST_DOWN) public Long getFirstDown() { return firstDown; } - @JsonSetter("first_down") + @JsonSetter(JsonFields.FIRST_DOWN) public void setFirstDown(Long firstDown) { this.firstDown = firstDown; } - @JsonGetter("last_try") + @JsonGetter(JsonFields.LAST_TRY) public Long getLastTry() { return lastTry; } - @JsonSetter("last_try") + @JsonSetter(JsonFields.LAST_TRY) public void setLastTry(Long lastTry) { this.lastTry = lastTry; } - @JsonGetter("lastContact") - public Long getLastContact() { - return lastContact; - } - - @JsonSetter("lastContact") - public void setLastContact(Long lastContact) { - this.lastContact = lastContact; - } - @JsonIgnore public String getHash() { return hash; diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/TxHistory.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/TxHistory.java index abbcab556f03b1721345c5306eff8732146ef4a9..a0fdbea9260bb682582044596b9bf7fee09068da 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/TxHistory.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/TxHistory.java @@ -22,6 +22,14 @@ package org.duniter.core.client.model.bma; * #L% */ +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonSetter; +import lombok.Data; +import lombok.experimental.FieldNameConstants; + +@Data +@FieldNameConstants public class TxHistory { private String currency; @@ -30,31 +38,9 @@ public class TxHistory { private History history; - public String getCurrency() { - return currency; - } - - public void setCurrency(String currency) { - this.currency = currency; - } - - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public History getHistory() { - return history; - } - - public void setHistory(History history) { - this.history = history; - } - - public class History { + @Data + @FieldNameConstants + public static class History { private Movement[] sent; @@ -63,42 +49,16 @@ public class TxHistory { private Movement[] sending; private Movement[] receiving; - - public Movement[] getSent() { - return sent; - } - - public void setSent(Movement[] sent) { - this.sent = sent; - } - - public Movement[] getReceived() { - return received; - } - - public void setReceived(Movement[] received) { - this.received = received; - } - - public Movement[] getSending() { - return sending; - } - - public void setSending(Movement[] sending) { - this.sending = sending; - } - - public Movement[] getReceiving() { - return receiving; - } - - public void setReceiving(Movement[] receiving) { - this.receiving = receiving; - } } + @Data + @FieldNameConstants public static class Movement { + public interface JsonFields { + String BLOCK_NUMBER = "block_number"; + } + private String version; private String[] issuers; @@ -113,102 +73,19 @@ public class TxHistory { private String hash; - private int block_number; + private int blockNumber; private long time; - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String[] getIssuers() { - return issuers; - } - - public void setIssuers(String[] issuers) { - this.issuers = issuers; - } - - public String[] getInputs() { - return inputs; - } - - public void setInputs(String[] inputs) { - this.inputs = inputs; - } - - public String[] getOutputs() { - return outputs; - } - - public void setOutputs(String[] outputs) { - this.outputs = outputs; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public String[] getSignatures() { - return signatures; - } - - public void setSignatures(String[] signatures) { - this.signatures = signatures; - } - - public String getHash() { - return hash; - } - - public String getFingerprint() { - return hash; - } - - public void setHash(String hash) { - this.hash = hash; - } - - /** - * @deprecated use getBlockNumber() instead - * @return - */ - @Deprecated - public int getBlock_number() { - return block_number; - } - - /** - * @deprecated use setBlockNumber() instead - * @return - */ - @Deprecated - public void setBlock_number(int block_number) { - this.block_number = block_number; - } - + @JsonGetter(JsonFields.BLOCK_NUMBER) public int getBlockNumber() { - return block_number; - } - - public void setNumber(int block_number) { - this.block_number = block_number; + return blockNumber; } - public long getTime() { - return time; + @JsonSetter(JsonFields.BLOCK_NUMBER) + public void setBlockNumber(int blockNumber) { + this.blockNumber = blockNumber; } - public void setTime(long time) { - this.time = time; - } } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/TxSource.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/TxSource.java index 010f225924c1d3f4ed1009595ea9533dc17bd3ff..2192174446b283c6befb241b6fc7558858477069 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/TxSource.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/TxSource.java @@ -23,8 +23,13 @@ package org.duniter.core.client.model.bma; */ +import lombok.Data; +import lombok.experimental.FieldNameConstants; + import java.io.Serializable; +@Data +@FieldNameConstants public class TxSource { private String currency; @@ -33,37 +38,20 @@ public class TxSource { private Source[] sources; - public TxSource() { - } - - public String getCurrency() { - return currency; - } - - public void setCurrency(String currency) { - this.currency = currency; - } - - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public Source[] getSources() { - return sources; - } - - public void setSources(Source[] sources) { - this.sources = sources; - } - + @Data + @FieldNameConstants public static class Source implements Serializable, Cloneable { private static final long serialVersionUID = 8084087351543574142L; + + /** + * Source type : <ul> + * <li><code>D</code> : Universal Dividend</li> + * <li><code>T</code> : Transaction</li> + * </ul> + * @return + */ private String type; private String identifier; private String noffset; @@ -71,9 +59,6 @@ public class TxSource { private String conditions; private int base; - public Source() { - } - @Override public Object clone() throws CloneNotSupportedException { @@ -86,64 +71,5 @@ public class TxSource { clone.base = base; return clone; } - - /** - * Source type : <ul> - * <li><code>D</code> : Universal Dividend</li> - * <li><code>T</code> : Transaction</li> - * </ul> - * @return - */ - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public String getNoffset() { - return noffset; - } - - public void setNoffset(String noffset) { - this.noffset = noffset; - } - - public long getAmount() { - return amount; - } - - public void setAmount(long amount) { - this.amount = amount; - } - - - public String getConditions() { - return conditions; - } - - public void setConditions(String conditions) { - this.conditions = conditions; - } - - public int getBase() { - return base; - } - - public void setBase(int base) { - this.base = base; - } - } - - } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotCertification.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotCertification.java index 2ec3cc3fb673ceb0cc32eae941a445f32d92b9d3..c325d4931c0fe16000b2302c352e3a665a88f51b 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotCertification.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotCertification.java @@ -25,6 +25,8 @@ package org.duniter.core.client.model.bma; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonSetter; +import lombok.Data; +import lombok.experimental.FieldNameConstants; import org.duniter.core.client.model.local.Identity; import java.io.Serializable; @@ -35,65 +37,28 @@ import java.io.Serializable; * @since 1.0 * */ +@Data +@FieldNameConstants public class WotCertification implements Serializable{ private static final long serialVersionUID = 8568496827055074607L; private String pubkey; - private String uid; - private String sigDate; - private boolean isMember; - private Certification[] certifications; - public Certification[] getCertifications() { - return certifications; - } - - public void setCertifications(Certification[] certifications) { - this.certifications = certifications; - } - - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - - @JsonGetter("is_member") - public boolean isMember() { - return isMember; - } - - public void setIsMember(boolean isMember) { - this.isMember = isMember; - } - - public String getSigDate() { - return sigDate; - } - - public void setSigDate(String sigDate) { - this.sigDate = sigDate; - } + @Data + @FieldNameConstants public static class Certification extends Identity { private static final long serialVersionUID = 2204517069552693026L; + public interface JsonFields { + String CERT_TIME = "cert_time"; + } private CertTime certTime; private String sigDate; @@ -105,91 +70,35 @@ public class WotCertification implements Serializable{ private boolean wasMember; - @JsonGetter("cert_time") + @JsonGetter(JsonFields.CERT_TIME) public CertTime getCertTime() { return certTime; } - @JsonSetter("cert_time") + @JsonSetter(JsonFields.CERT_TIME) public void setCertTime(CertTime certTime) { this.certTime = certTime; } - /** - * Indicate whether the certification is written in the blockchain or not. - */ - public Written getWritten() { - return written; - } - - public void setWritten(Written written) { - this.written = written; - } - - public String getSigDate() { - return sigDate; - } - - public void setSigDate(String sigDate) { - this.sigDate = sigDate; - } - - @JsonGetter("wasMember") - public boolean wasMember() { - return wasMember; - } - - public void setWasMember(boolean wasMember) { - this.wasMember = wasMember; - } } + @Data + @FieldNameConstants public static class CertTime implements Serializable { private static final long serialVersionUID = -358639516878884523L; private int block = -1; - private long medianTime = -1; - public int getBlock() { - return block; - } - - public void setBlock(int block) { - this.block = block; - } - - public long getMedianTime() { - return medianTime; - } - - public void setMedianTime(long medianTime) { - this.medianTime = medianTime; - } - } + @Data + @FieldNameConstants public static class Written implements Serializable{ private long number = -1; - private String hash = ""; - public long getNumber() { - return number; - } - - public void setNumber(long number) { - this.number = number; - } - - public String getHash() { - return hash; - } - - public void setHash(String hash) { - this.hash = hash; - } } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotLookup.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotLookup.java index 9118eceef928c50d30167b17635e5e30893f26f0..ae6df0db2e8f5afefc1c39892c5ea4b604d89135 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotLookup.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotLookup.java @@ -25,30 +25,17 @@ package org.duniter.core.client.model.bma; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonSetter; +import lombok.Data; +import lombok.experimental.FieldNameConstants; import java.io.Serializable; - +@Data +@FieldNameConstants public class WotLookup { private boolean partial; private Result[] results; - public boolean isPartial() { - return partial; - } - - public void setPartial(boolean partial) { - this.partial = partial; - } - - public Result[] getResults() { - return results; - } - - public void setResults(Result[] results) { - this.results = results; - } - public String toString() { String s = ""; for (Result result : results) { @@ -62,6 +49,8 @@ public class WotLookup { return s; } + @Data + @FieldNameConstants public static class Result implements Serializable { private static final long serialVersionUID = -39452685440482106L; @@ -70,33 +59,16 @@ public class WotLookup { private Uid[] uids; private SignedSignature[] signed; - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public Uid[] getUids() { - return uids; - } - - public void setUids(Uid[] uids) { - this.uids = uids; - } - - public SignedSignature[] getSigned() { - return signed; - } - - public void setSigned(SignedSignature[] signed) { - this.signed = signed; - } } + @Data + @FieldNameConstants public static class Uid { + public interface JsonFields { + String REVOCATION_SIG="revocation_sig"; + String REVOKED_ON="revoked_on"; + } private String uid; private Meta meta; private String self; @@ -105,106 +77,65 @@ public class WotLookup { private String revocationSig; private OtherSignature[] others; - public Uid(){ - - } - - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - public Meta getMeta() { - return meta; - } - - public void setMeta(Meta meta) { - this.meta = meta; - } - - public String getSelf() { - return self; - } - - public void setSelf(String self) { - this.self = self; - } - - public OtherSignature[] getOthers() { - return others; - } - - public void setOthers(OtherSignature[] others) { - this.others = others; - } - - public Boolean getRevoked() { - return revoked; - } - - public void setRevoked(Boolean revoked) { - this.revoked = revoked; - } - - @JsonGetter("revocation_sig") + @JsonGetter(JsonFields.REVOCATION_SIG) public String getRevocationSig() { return revocationSig; } - @JsonSetter("revocation_sig") + @JsonSetter(JsonFields.REVOCATION_SIG) public void setRevocationSig(String revocationSig) { this.revocationSig = revocationSig; } - @JsonGetter("revoked_on") + @JsonGetter(JsonFields.REVOKED_ON) public Long getRevokedOn() { return revokedOn; } - @JsonSetter("revoked_on") + @JsonSetter(JsonFields.REVOKED_ON) public void setRevokedOn(Long revokedOn) { this.revokedOn = revokedOn; } } - + @Data + @FieldNameConstants public static class Meta implements Serializable { + + public interface JsonFields { + String BLOCK_HASH="block_hash"; + String BLOCK_NUMBER="block_number"; + } + private String timestamp; private String blockHash; private Long blockNumber; - public String getTimestamp() { - return timestamp; - } - - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } - @JsonGetter("block_hash") + @JsonGetter(JsonFields.BLOCK_HASH) public String getBlockHash() { return blockHash; } - @JsonSetter("block_hash") + @JsonSetter(JsonFields.BLOCK_HASH) public void setBlockHash(String blockHash) { this.blockHash = blockHash; } - @JsonGetter("block_number") + @JsonGetter(JsonFields.BLOCK_NUMBER) public Long getBlockNumber() { return blockNumber; } - @JsonSetter("block_number") + @JsonSetter(JsonFields.BLOCK_NUMBER) public void setBlockNumberH(Long blockNumber) { this.blockNumber = blockNumber; } } + @Data + @FieldNameConstants public static class OtherSignature { private String pubkey; @@ -213,60 +144,14 @@ public class WotLookup { private String[] uids; private boolean isMember; private boolean wasMember; - - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public Meta getMeta() { - return meta; - } - - public void setMeta(Meta meta) { - this.meta = meta; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; - } - - public String[] getUids() { - return uids; - } - - public void setUids(String[] uids) { - this.uids = uids; - } - - @JsonGetter("isMember") - public boolean isMember() { - return isMember; - } - - @JsonSetter("isMember") - public void setMember(boolean member) { - isMember = member; - } - - @JsonGetter("wasMember") - public boolean wasMember() { - return wasMember; - } - - public void setWasMember(boolean wasMember) { - this.wasMember = wasMember; - } } + @Data + @FieldNameConstants public static class SignedSignature { + public interface JsonFields { + String CERT_TIME="cert_time"; + } private String uid; private String pubkey; @@ -276,85 +161,33 @@ public class WotLookup { private boolean isMember; private boolean wasMember; - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public Meta getMeta() { - return meta; - } - - public void setMeta(Meta meta) { - this.meta = meta; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; - } - - @JsonGetter("isMember") - public boolean isMember() { - return isMember; - } - - public void setIsMember(boolean isMember) { - this.isMember = isMember; - } - - @JsonGetter("wasMember") - public boolean wasMember() { - return wasMember; - } - - public void setWasMember(boolean wasMember) { - this.wasMember = wasMember; - } - - @JsonGetter("cert_time") + @JsonGetter(JsonFields.CERT_TIME) public CertTime getCerTime() { return cerTime; } - @JsonSetter("cert_time") + @JsonSetter(JsonFields.CERT_TIME) public void setCerTime(CertTime cerTime) { this.cerTime = cerTime; } } + @Data + @FieldNameConstants public static class CertTime implements Serializable { - private Long block; - private String blockHash; - - public Long getBlock() { - return block; + public interface JsonFields { + String BLOCK_HASH="block_hash"; } - public void setBlock(Long block) { - this.block = block; - } + private Long block; + private String blockHash; - @JsonGetter("block_hash") + @JsonGetter(JsonFields.BLOCK_HASH) public String getBlockHash() { return blockHash; } - @JsonSetter("block_hash") + @JsonSetter(JsonFields.BLOCK_HASH) public void setBlockHash(String blockHash) { this.blockHash = blockHash; } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotPendingMembership.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotPendingMembership.java index 814fa61ffbd0d83d4801e788e1956fef563ed255..918e3a3da0855360dd02ff99b6b8bf65401f0983 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotPendingMembership.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotPendingMembership.java @@ -22,20 +22,16 @@ package org.duniter.core.client.model.bma; * #L% */ +import lombok.Data; +import lombok.experimental.FieldNameConstants; + import java.io.Serializable; +@Data +@FieldNameConstants public class WotPendingMembership implements Serializable { - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_PUBKEY = "pubkey"; - public static final String PROPERTY_UID = "uid"; - public static final String PROPERTY_VERSION = "version"; - public static final String PROPERTY_CURRENCY = "currency"; - public static final String PROPERTY_MEMBERSHIP = "membership"; - public static final String PROPERTY_BLOCK_NUMBER = "blockNumber"; - public static final String PROPERTY_BLOCK_HASH = "blockHash"; - public static final String PROPERTY_WRITTEN = "written"; + private static final long serialVersionUID = 1L; private String pubkey; private String uid; @@ -46,54 +42,5 @@ public class WotPendingMembership implements Serializable { private String blockHash; private Boolean written; - public String getPubkey() { - return pubkey; - } - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - public String getUid() { - return uid; - } - public void setUid(String uid) { - this.uid = uid; - } - public String getVersion() { - return version; - } - public void setVersion(String version) { - this.version = version; - } - public String getCurrency() { - return currency; - } - public void setCurrency(String currency) { - this.currency = currency; - } - public String getMembership() { - return membership; - } - public void setMembership(String membership) { - this.membership = membership; - } - public long getBlockNumber() { - return blockNumber; - } - public void setBlockNumber(Integer blockNumber) { - this.blockNumber = blockNumber; - } - public String getBlockHash() { - return blockHash; - } - public void setBlockHash(String blockHash) { - this.blockHash = blockHash; - } - - public Boolean getWritten() { - return written; - } - public void setWritten(Boolean written) { - this.written = written; - } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotPendingMemberships.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotPendingMemberships.java index 86eb3cce2d05ec4b7fcef810a5fad06344ace716..79a0eb1542139eb28f89721eb19e32de0f0055da 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotPendingMemberships.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotPendingMemberships.java @@ -22,19 +22,16 @@ package org.duniter.core.client.model.bma; * #L% */ +import lombok.Data; +import lombok.experimental.FieldNameConstants; + import java.io.Serializable; +@Data +@FieldNameConstants public class WotPendingMemberships implements Serializable { private static final long serialVersionUID = -5631089862725952431L; private WotPendingMembership[] memberships; - public WotPendingMembership[] getMemberships() { - return memberships; - } - - public void setMemberships(WotPendingMembership[] value) { - memberships = value; - } - } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotRequirements.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotRequirements.java index 5aaedf5b9b01e01079d030eebc3bafb7791276cf..45f2bb90ec5b7ffe7c5fa245313c99e60fbf85a8 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotRequirements.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotRequirements.java @@ -24,9 +24,13 @@ package org.duniter.core.client.model.bma; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonSetter; +import lombok.Data; +import lombok.experimental.FieldNameConstants; import java.io.Serializable; +@Data +@FieldNameConstants public class WotRequirements implements Serializable { private static final long serialVersionUID = 1L; @@ -42,163 +46,21 @@ public class WotRequirements implements Serializable { private Boolean isSentry; private Boolean wasMember; - private Certification[] certifications; - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - - public String getSig() { - return sig; - } - - public void setSig(String sig) { - this.sig = sig; - } - - public Meta getMeta() { - return meta; - } - - public void setMeta(Meta meta) { - this.meta = meta; - } - - public String getRevocation_sig() { - return revocation_sig; - } - - public void setRevocation_sig(String revocation_sig) { - this.revocation_sig = revocation_sig; - } - - public Boolean getRevoked() { - return revoked; - } - - public void setRevoked(Boolean revoked) { - this.revoked = revoked; - } - - public Long getRevoked_on() { - return revoked_on; - } - - public void setRevoked_on(Long revoked_on) { - this.revoked_on = revoked_on; - } - - public Boolean getExpired() { - return expired; - } - - public void setExpired(Boolean expired) { - this.expired = expired; - } - - public Boolean getOutdistanced() { - return outdistanced; - } - - public void setOutdistanced(Boolean outdistanced) { - this.outdistanced = outdistanced; - } - - public Boolean getIsSentry() { - return isSentry; - } - - public void setIsSentry(Boolean sentry) { - isSentry = sentry; - } - - public Boolean getWasMember() { - return wasMember; - } - - public void setWasMember(Boolean wasMember) { - this.wasMember = wasMember; - } - - - public Certification[] getCertifications() { - return certifications; - } - - public void setCertifications(Certification[] certifications) { - this.certifications = certifications; - } - + @Data + @FieldNameConstants public static class Meta implements Serializable { private String timestamp; - - public String getTimestamp() { - return timestamp; - } - - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } } + @Data + @FieldNameConstants public static class Certification implements Serializable { private long timestamp; private String from; private String to; private String sig; private long expiresIn; - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public String getTo() { - return to; - } - - public void setTo(String to) { - this.to = to; - } - - public String getSig() { - return sig; - } - - public void setSig(String sig) { - this.sig = sig; - } - - public long getExpiresIn() { - return expiresIn; - } - - public void setExpiresIn(long expiresIn) { - this.expiresIn = expiresIn; - } } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotRequirementsResponse.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotRequirementsResponse.java index f4245567c144564b20e247f35179714918b6e073..3fbcc01aa8158b4d27ea77a2ff5b9c087cb6c398 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotRequirementsResponse.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/WotRequirementsResponse.java @@ -22,19 +22,14 @@ package org.duniter.core.client.model.bma; * #L% */ +import lombok.Data; +import lombok.experimental.FieldNameConstants; import org.duniter.core.client.model.BaseIdentity; +@Data +@FieldNameConstants public class WotRequirementsResponse extends BaseIdentity { private static final long serialVersionUID = -5631089862725952141L; private WotRequirements[] identities; - - public WotRequirements[] getIdentities() { - return identities; - } - - public void setIdentities(WotRequirements[] value) { - identities = value; - } - } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/Ws2pHead.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/Ws2pHead.java index 0813f9327129efe1a71c1e6c221dc6aff7bc7225..f481a325708c847f6a38079aab05a78901867093 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/Ws2pHead.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/Ws2pHead.java @@ -24,36 +24,18 @@ package org.duniter.core.client.model.bma; import com.fasterxml.jackson.annotation.JsonIgnore; import com.google.common.base.Joiner; +import lombok.Data; +import lombok.experimental.FieldNameConstants; import java.io.Serializable; /** * Created by blavenie on 22/01/19. */ +@Data +@FieldNameConstants public class Ws2pHead implements Serializable { - - public class AccessConfig { - public boolean useTor; - private String mode; - - public boolean isUseTor() { - return useTor; - } - - public void setUseTor(boolean useTor) { - this.useTor = useTor; - } - - public String getMode() { - return mode; - } - - public void setMode(String mode) { - this.mode = mode; - } - } - public Integer version; public String pubkey; public String block; @@ -67,84 +49,12 @@ public class Ws2pHead implements Serializable { public AccessConfig privateConfig = new AccessConfig(); public AccessConfig publicConfig = new AccessConfig(); - public Integer getVersion() { - return version; - } - - public void setVersion(Integer version) { - this.version = version; - } - - public String getPubkey() { - return pubkey; - } - - public void setPubkey(String pubkey) { - this.pubkey = pubkey; - } - - public String getBlock() { - return block; - } - - public void setBlock(String block) { - this.block = block; - } - - public String getWs2pid() { - return ws2pid; - } - - public void setWs2pid(String ws2pid) { - this.ws2pid = ws2pid; - } - - public String getSoftware() { - return software; - } - - public void setSoftware(String software) { - this.software = software; - } - - public String getSoftwareVersion() { - return softwareVersion; - } - - public void setSoftwareVersion(String softwareVersion) { - this.softwareVersion = softwareVersion; - } - - public String getPowPrefix() { - return powPrefix; - } - - public void setPowPrefix(String powPrefix) { - this.powPrefix = powPrefix; - } - - public AccessConfig getPrivateConfig() { - return privateConfig; - } - - public void setPrivateConfig(AccessConfig privateConfig) { - this.privateConfig = privateConfig; - } - - public AccessConfig getPublicConfig() { - return publicConfig; - } - public void setPublicConfig(AccessConfig publicConfig) { - this.publicConfig = publicConfig; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; + @Data + @FieldNameConstants + public static class AccessConfig { + public boolean useTor; + private String mode; } @Override diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/DeleteRecord.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/DeleteRecord.java deleted file mode 100644 index c09fe0d125212863155ea662b67b071fa39676f1..0000000000000000000000000000000000000000 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/DeleteRecord.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.duniter.core.client.model.elasticsearch; - -/* - * #%L - * Duniter4j :: Core Client API - * %% - * Copyright (C) 2014 - 2016 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -/** - * Created by blavenie on 01/03/16. - */ -public class DeleteRecord extends Record { - - public static final String PROPERTY_INDEX="index"; - public static final String PROPERTY_TYPE="type"; - public static final String PROPERTY_ID="id"; - - private String index; - private String type; - private String id; - - public String getIndex() { - return index; - } - - public void setIndex(String index) { - this.index = index; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } -} diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Message.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Message.java deleted file mode 100644 index 16102aaa8464694b5d03ed438ae261467c5ab778..0000000000000000000000000000000000000000 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Message.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.duniter.core.client.model.elasticsearch; - -/* - * #%L - * Duniter4j :: Core Client API - * %% - * Copyright (C) 2014 - 2016 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonSetter; - -/** - * Created by blavenie on 01/03/16. - */ -public class Message extends Record { - - public static final String PROPERTY_TITLE="title"; - public static final String PROPERTY_CONTENT="content"; - public static final String PROPERTY_RECIPIENT="recipient"; - public static final String PROPERTY_READ_SIGNATURE="read_signature"; - - private String title; - private String content; - private String recipient; - private String readSignature; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getRecipient() { - return recipient; - } - - public void setRecipient(String recipient) { - this.recipient = recipient; - } - - @JsonGetter(PROPERTY_READ_SIGNATURE) - public String getReadSignature() { - return readSignature; - } - - @JsonSetter(PROPERTY_READ_SIGNATURE) - public void setReadSignature(String readSignature) { - this.readSignature = readSignature; - } - -} diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Peer.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Peer.java deleted file mode 100644 index 35b5faaa67f14e86fa119728f2f2f89b20390175..0000000000000000000000000000000000000000 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Peer.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.duniter.core.client.model.elasticsearch; - -/* - * #%L - * Duniter4j :: Core API - * %% - * Copyright (C) 2014 - 2015 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - - -import java.io.Serializable; - -public class Peer implements Serializable { - - private String currency; - private String host; - private int port; - private String path; - private String url; - - public Peer() { - // default constructor, need for de-serialization - } - - public Peer(String host, int port) { - this(host, port, null); - } - - public Peer(String host, int port, String path) { - this.host = host; - this.port = port; - this.url = initUrl(host, port, path); - this.path = path; - } - - public String getHost() { - return host; - } - - public int getPort() { - return port; - } - - public String getUrl() { - return url; - } - - public String getCurrency() { - return currency; - } - - public void setCurrency(String currency) { - this.currency = currency; - } - - public void setPort(int port) { - this.port = port; - this.url = initUrl(host, port, path); - } - - public void setHost(String host) { - this.host = host; - this.url = initUrl(host, port, path); - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - this.url = initUrl(host, port, path); - } - - public String toString() { - return new StringBuilder().append(host) - .append(":") - .append(port) - .toString(); - } - - @Override - public boolean equals(Object o) { - if (o == null) { - return false; - } - if (currency != null && o instanceof Peer) { - if (!currency.equals(((Peer) o).getCurrency())) { - return false; - } - if (!getUrl().equals(((Peer) o).getUrl())) { - return false; - } - } - return super.equals(o); - } - - /* -- Internal methods -- */ - - protected String initUrl(String host, int port, String path) { - return String.format("%s://%s:%s%s", - port == 443 ? "https" : "http", - host, port, - (path != null) ? path : ""); - } -} diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Protocol.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Protocol.java deleted file mode 100644 index 1fdb62aee7a26a295ad3028d9cb2262a1f84e480..0000000000000000000000000000000000000000 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Protocol.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.duniter.core.client.model.elasticsearch; - -/* - * #%L - * Duniter4j :: Core Client API - * %% - * Copyright (C) 2014 - 2016 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -/** - * Created by blavenie on 31/03/16. - */ -public interface Protocol { - - String VERSION = "1"; - - String ES_API = "ELASTICSEARCH_API"; - - String CESIUM_PLUS_API = "CESIUM_PLUS_API"; -} diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Record.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Record.java deleted file mode 100644 index de8a49fb6a79c82e7034af1072f1eb12ab8404cb..0000000000000000000000000000000000000000 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Record.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.duniter.core.client.model.elasticsearch; - -/* - * #%L - * Duniter4j :: Core Client API - * %% - * Copyright (C) 2014 - 2016 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.fasterxml.jackson.annotation.JsonIgnore; -import org.duniter.core.model.IEntity; - -/** - * Created by blavenie on 01/03/16. - */ -public class Record implements IEntity<String> { - - public static final String PROPERTY_VERSION="version"; - public static final String PROPERTY_ISSUER="issuer"; - public static final String PROPERTY_HASH="hash"; - public static final String PROPERTY_SIGNATURE="signature"; - public static final String PROPERTY_TIME="time"; - - private Integer version; - private String id; - private String issuer; - private String hash; - private String signature; - private Long time; - - public Record() { - } - - public Record(Record another) { - this.version = another.getVersion(); - this.id = another.getId(); - this.issuer = another.getIssuer(); - this.hash = another.getHash(); - this.signature = another.getSignature(); - this.time = another.getTime(); - } - - public Integer getVersion() { - return version; - } - - public void setVersion(Integer version) { - this.version = version; - } - - @JsonIgnore - public String getId() { - return id; - } - - @JsonIgnore - public void setId(String id) { - this.id = id; - } - - public String getIssuer() { - return issuer; - } - - public void setIssuer(String issuer) { - this.issuer = issuer; - } - - public String getHash() { - return hash; - } - - public void setHash(String hash) { - this.hash = hash; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; - } - - - public Long getTime() { - return time; - } - - public void setTime(Long time) { - this.time = time; - } - -} diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/RecordComment.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/RecordComment.java deleted file mode 100644 index 6274a5b1ac9f4bd2d8919a8bff2d4caa845d6591..0000000000000000000000000000000000000000 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/RecordComment.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.duniter.core.client.model.elasticsearch; - -/* - * #%L - * Duniter4j :: Core Client API - * %% - * Copyright (C) 2014 - 2016 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonSetter; - -/** - * Created by blavenie on 01/03/16. - */ -public class RecordComment extends Record { - - public static final String PROPERTY_MESSAGE="message"; - public static final String PROPERTY_RECORD="record"; - public static final String PROPERTY_REPLY_TO="replyTo"; - - public static final String PROPERTY_REPLY_TO_JSON="reply_to"; - - private String message; - private String record; - private String replyTo; - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getRecord() { - return record; - } - - public void setRecord(String record) { - this.record = record; - } - - @JsonGetter(PROPERTY_REPLY_TO_JSON) - public String getReplyTo() { - return replyTo; - } - - @JsonSetter(PROPERTY_REPLY_TO_JSON) - public void setReplyTo(String replyTo) { - this.replyTo = replyTo; - } -} diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Records.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Records.java deleted file mode 100644 index 23198ee37d03aa27e54f186e16e95dccfadc467f..0000000000000000000000000000000000000000 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Records.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.duniter.core.client.model.elasticsearch; - -/* - * #%L - * Duniter4j :: Core Client API - * %% - * Copyright (C) 2014 - 2016 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -/** - * Helper class - * Created by blavenie on 01/03/16. - */ -public final class Records { - - // Common fields - public static final String PROPERTY_ISSUER="issuer"; - public static final String PROPERTY_HASH="hash"; - public static final String PROPERTY_SIGNATURE="signature"; - public static final String PROPERTY_VERSION="version"; - public static final String PROPERTY_TIME="time"; - public static final String PROPERTY_CREATION_TIME="creationTime"; - - // Read marker - public static final String PROPERTY_READ_SIGNATURE="read_signature"; - - // Location - public static final String PROPERTY_ADDRESS="address"; - public static final String PROPERTY_CITY="city"; - public static final String PROPERTY_GEO_POINT="geoPoint"; - - // record - public static final String PROPERTY_TITLE="title"; - public static final String PROPERTY_DESCRIPTION="description"; - - // Avatar & pictures - public static final String PROPERTY_AVATAR="avatar"; - public static final String PROPERTY_PICTURES="pictures"; - public static final String PROPERTY_PICTURES_COUNT="picturesCount"; - - // Socials & tags - public static final String PROPERTY_SOCIALS="socials"; - public static final String PROPERTY_TAGS="tags"; - - // Other - public static final String PROPERTY_CATEGORY="category"; - public static final String PROPERTY_CONTENT="content"; - - - -} diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/UserGroup.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/UserGroup.java deleted file mode 100644 index 5a0fc2ea9da2902d0a685f019b06d3ef39285471..0000000000000000000000000000000000000000 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/UserGroup.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.duniter.core.client.model.elasticsearch; - -/* - * #%L - * Duniter4j :: Core Client API - * %% - * Copyright (C) 2014 - 2016 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import java.util.HashMap; -import java.util.Map; - -/** - * Created by blavenie on 01/03/16. - */ -public class UserGroup extends Record { - - public static final String PROPERTY_TITLE="title"; - public static final String PROPERTY_DESCRIPTION="description"; - public static final String PROPERTY_CREATION_TIME="creationTime"; - public static final String PROPERTY_AVATAR="avatar"; - - private String title; - private String description; - private Long creationTime; - private Map<String, String> avatar = new HashMap<>(); - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Long getCreationTime() { - return creationTime; - } - - public void setCreationTime(Long creationTime) { - this.creationTime = creationTime; - } - - public Map<String, String> getAvatar() { - return avatar; - } - - public void setAvatar(Map<String, String> avatar) { - this.avatar = avatar; - } - -} diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/UserProfile.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/UserProfile.java deleted file mode 100644 index dca4bc89951f1e314584c0695a64d3a6998863b2..0000000000000000000000000000000000000000 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/UserProfile.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.duniter.core.client.model.elasticsearch; - -/* - * #%L - * Duniter4j :: Core Client API - * %% - * Copyright (C) 2014 - 2016 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -/** - * Created by blavenie on 01/03/16. - */ -public class UserProfile extends Record { - - public static final String PROPERTY_TITLE = "title"; - public static final String PROPERTY_DESCRIPTION="description"; - public static final String PROPERTY_ADDRESS="address"; - public static final String PROPERTY_CITY="city"; - public static final String PROPERTY_EMAIL="email"; - public static final String PROPERTY_LOCALE="locale"; - - private String title; - private String description; - private String address; - private String email; - private String locale; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getLocale() { - return locale; - } - - public void setLocale(String locale) { - this.locale = locale; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } -} diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Currency.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Currency.java index a6aa5d6d31e55f145fabdec981f452a5ec2c0783..8019418b45b473dd3ba90af9aa2a94df2c2d5bd5 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Currency.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Currency.java @@ -25,10 +25,8 @@ package org.duniter.core.client.model.local; import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; +import lombok.experimental.FieldNameConstants; import org.duniter.core.client.model.bma.BlockchainParameters; /** @@ -36,9 +34,13 @@ import org.duniter.core.client.model.bma.BlockchainParameters; */ @Data @Builder +@FieldNameConstants @NoArgsConstructor @AllArgsConstructor public class Currency implements ICurrency { + @NoArgsConstructor(access = AccessLevel.PROTECTED) + public static class Fields {} + private String id; private BlockchainParameters parameters; private String firstBlockSignature; diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Identity.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Identity.java index 5588633cabb4b09d2e471efea4893e100eeeb41e..fed22a920ce2deeff4b545aad1a0d2909b89f68d 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Identity.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Identity.java @@ -24,12 +24,19 @@ package org.duniter.core.client.model.local; import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AccessLevel; import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.FieldNameConstants; import org.duniter.core.client.model.BaseIdentity; @Data +@FieldNameConstants public class Identity extends BaseIdentity { + @NoArgsConstructor(access = AccessLevel.PROTECTED) + public static class Fields extends BaseIdentity.Fields {} + private String currency; // The timestamp value of the signature date (a BLOCK_UID) diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Member.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Member.java index f462d71b74d1e9588e7c8f45764e544c28d6d1c9..fc416e154f0d3f5e6dcb8150a9dd74737c8071de 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Member.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Member.java @@ -24,10 +24,17 @@ package org.duniter.core.client.model.local; import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import lombok.experimental.FieldNameConstants; +import org.duniter.core.client.model.BaseIdentity; import org.duniter.core.model.IEntity; +@Data +@FieldNameConstants public class Member extends Identity implements IEntity<String> { + public static class Fields extends Identity.Fields {} + private static final long serialVersionUID = 8448049949323699700L; @JsonIgnore diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Peer.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Peer.java index a6fdf0595826d1f1555a7735fbdac1049a95d744..34e52592a917a76d7789b652f81f36ccfd005f53 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Peer.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Peer.java @@ -26,6 +26,7 @@ package org.duniter.core.client.model.local; import com.fasterxml.jackson.annotation.JsonIgnore; import com.google.common.base.Preconditions; import lombok.Data; +import lombok.experimental.FieldNameConstants; import org.apache.commons.lang3.StringUtils; import org.duniter.core.client.model.bma.EndpointApi; import org.duniter.core.client.model.bma.NetworkPeering; @@ -35,6 +36,7 @@ import org.duniter.core.util.http.InetAddressUtils; import java.util.StringJoiner; @Data +@FieldNameConstants public class Peer implements IEntity<String> { public static Builder builder() { @@ -483,12 +485,9 @@ public class Peer implements IEntity<String> { ERROR } + @Data + @FieldNameConstants public static class Peering { - public static final String PROPERTY_VERSION = "version"; - public static final String PROPERTY_SIGNATURE = "signature"; - public static final String PROPERTY_BLOCK_NUMBER = "blockNumber"; - public static final String PROPERTY_BLOCK_HASH = "blockHash"; - public static final String PROPERTY_RAW = "raw"; private Integer version; private String signature; @@ -496,58 +495,11 @@ public class Peer implements IEntity<String> { private String blockHash; private String raw; - public Integer getVersion() { - return version; - } - - public void setVersion(Integer version) { - this.version = version; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; - } - - public Integer getBlockNumber() { - return blockNumber; - } - - public void setBlockNumber(Integer blockNumber) { - this.blockNumber = blockNumber; - } - - public String getBlockHash() { - return blockHash; - } - - public void setBlockHash(String blockHash) { - this.blockHash = blockHash; - } - - /** - * The raw peering document (unsigned) - * @return - */ - public String getRaw() { - return raw; - } - - public void setRaw(String raw) { - this.raw = raw; - } } + @Data + @FieldNameConstants public static class Stats { - public static final String PROPERTY_SOFTWARE = "software"; - public static final String PROPERTY_VERSION = "version"; - public static final String PROPERTY_STATUS = "status"; - public static final String PROPERTY_UID = "uid"; - public static final String PROPERTY_LAST_UP_TIME = "lastUpTime"; - public static final String PROPERTY_FIRST_DOWN_TIME = "firstDownTime"; private String software; private String version; @@ -564,133 +516,12 @@ public class Peer implements IEntity<String> { private Long lastUpTime; private Long firstDownTime; - public Stats() { - - } - - public PeerStatus getStatus() { - return status; - } @JsonIgnore public boolean isReacheable() { return status != null && status == PeerStatus.UP; } - public void setStatus(PeerStatus status) { - this.status = status; - } - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - - public String getSoftware() { - return software; - } - - public void setSoftware(String software) { - this.software = software; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public Integer getBlockNumber() { - return blockNumber; - } - public void setBlockNumber(Integer blockNumber) { - this.blockNumber = blockNumber; - } - - public String getBlockHash() { - return blockHash; - } - - public void setBlockHash(String blockHash) { - this.blockHash = blockHash; - } - - public Long getMedianTime() { - return medianTime; - } - - public void setMedianTime(Long medianTime) { - this.medianTime = medianTime; - } - - public boolean isMainConsensus() { - return isMainConsensus; - } - - public void setMainConsensus(boolean mainConsensus) { - this.isMainConsensus = mainConsensus; - } - - public boolean isForkConsensus() { - return isForkConsensus; - } - - public void setForkConsensus(boolean forkConsensus) { - this.isForkConsensus = forkConsensus; - } - - public Double getConsensusPct() { - return consensusPct; - } - - public void setConsensusPct(Double consensusPct) { - this.consensusPct = consensusPct; - } - - public Integer getHardshipLevel() { - return hardshipLevel; - } - - public void setHardshipLevel(Integer hardshipLevel) { - this.hardshipLevel = hardshipLevel; - } - - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - - /** - * Last time the peer was UP (in second) - * @return - */ - public Long getLastUpTime() { - return lastUpTime; - } - - public void setLastUpTime(Long lastUpTime) { - this.lastUpTime = lastUpTime; - } - - /** - * First time the peer was DOWN (in second) - * @return - */ - public Long getFirstDownTime() { - return firstDownTime; - } - - public void setFirstDownTime(Long firstDownTime) { - this.firstDownTime = firstDownTime; - } } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/elasticsearch/CurrencyPodRemoteServiceImpl.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/elasticsearch/CurrencyPodRemoteServiceImpl.java index 8c03aecf9abdd592698e270202e029fee66bc761..1a5c320e84bee223b134bcc6d301e9ce36b6afb7 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/elasticsearch/CurrencyPodRemoteServiceImpl.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/elasticsearch/CurrencyPodRemoteServiceImpl.java @@ -58,7 +58,7 @@ public class CurrencyPodRemoteServiceImpl extends BaseRemoteServiceImpl implemen public void afterPropertiesSet() { super.afterPropertiesSet(); config = Configuration.instance(); - peer = Peer.builder().host(config.getNodeElasticSearchHost()).port(config.getNodeElasticSearchPort()).build(); + peer = Peer.builder().host(config.getCesiumPlusPodHost()).port(config.getCesiumPlusPodPort()).build(); } @Override diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/local/DividendService.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/local/DividendService.java index b07d3765d3838653458f74de5a059c7b6516be3b..8ebc362e615ffc2cb2c17575feda1740923429cd 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/local/DividendService.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/local/DividendService.java @@ -23,11 +23,9 @@ package org.duniter.core.client.service.local; */ import org.duniter.core.beans.Service; -import org.duniter.core.client.model.local.Currency; import java.util.Map; import java.util.Optional; -import java.util.Set; /** * Created by eis on 07/02/15. @@ -51,7 +49,7 @@ public interface DividendService extends Service { * Return a map of UD (key=blockNumber, value=amount) * @return */ - Map<Integer, Long> findAllUdByCurrency(String currency); + Map<Integer, Long> findAllDividendsByCurrency(String currency); /** * Update the last currency dividend diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/local/DividendServiceImpl.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/local/DividendServiceImpl.java index 55f24b1d59c8ab84bf068e134a563f821795f105..9766d987487b2a22290e15effcad2d226dd2a64d 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/local/DividendServiceImpl.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/local/DividendServiceImpl.java @@ -140,14 +140,14 @@ public class DividendServiceImpl implements DividendService, InitializingBean { } // Return the full list - return findAllUdByCurrency(currency); + return findAllDividendsByCurrency(currency); } /** * Return a map of UD (key=blockNumber, value=amount) * @return */ - public Map<Integer, Long> findAllUdByCurrency(String currency) { + public Map<Integer, Long> findAllDividendsByCurrency(String currency) { return Beans.getStream(dividendRepository.findAllByCurrency(currency)) .collect(Collectors.toMap(Dividend::getNumber, Dividend::getDividend)); } diff --git a/duniter4j-core-client/src/test/java/org/duniter/core/client/service/elasticsearch/CurrencyPodRemoteServiceTest.java b/duniter4j-core-client/src/test/java/org/duniter/core/client/service/elasticsearch/CurrencyPodRemoteServiceTest.java index e80465989f4286160235ee1111840b959bef0e61..486e9669754af4f7dabb35c66bcfa1a3b421f995 100644 --- a/duniter4j-core-client/src/test/java/org/duniter/core/client/service/elasticsearch/CurrencyPodRemoteServiceTest.java +++ b/duniter4j-core-client/src/test/java/org/duniter/core/client/service/elasticsearch/CurrencyPodRemoteServiceTest.java @@ -49,8 +49,8 @@ public class CurrencyPodRemoteServiceTest { // Make sure ES node is alive if (!service.isNodeAlive()) { log.warn(String.format("Unable to connect to elasticsearch node [%s:%s]. Skipping test.", - config.getNodeElasticSearchHost(), - config.getNodeElasticSearchPort())); + config.getCesiumPlusPodHost(), + config.getCesiumPlusPodPort())); Assume.assumeTrue(false); } } diff --git a/duniter4j-core-shared/pom.xml b/duniter4j-core-shared/pom.xml index 853b993de7a54ad127109f1f295895b8b60eff10..e8fa8722fa0ce98a6213b016b8135138fd6a4dbb 100644 --- a/duniter4j-core-shared/pom.xml +++ b/duniter4j-core-shared/pom.xml @@ -81,10 +81,6 @@ <artifactId>nuiton-i18n</artifactId> </dependency> - <dependency> - <groupId>jakarta.mail</groupId> - <artifactId>jakarta.mail-api</artifactId> - </dependency> <dependency> <groupId>com.sun.mail</groupId> <artifactId>jakarta.mail</artifactId> diff --git a/duniter4j-core-shared/src/main/java/org/duniter/core/util/Beans.java b/duniter4j-core-shared/src/main/java/org/duniter/core/util/Beans.java index a241e7448203dd6b91406d92c0a1870e1d849347..c7d4d53ddc5829b6f52dd69c8695e46670c75687 100644 --- a/duniter4j-core-shared/src/main/java/org/duniter/core/util/Beans.java +++ b/duniter4j-core-shared/src/main/java/org/duniter/core/util/Beans.java @@ -37,9 +37,11 @@ import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.util.*; import java.util.function.Function; +import java.util.function.IntFunction; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; +import java.util.stream.StreamSupport; /** * helper class for beans (split by property, make sure list exists, ...) @@ -68,6 +70,59 @@ public class Beans { } } + /** + * <p>getList.</p> + * + * @param list a {@link Iterable} object. + * @param <E> a E object. + * @return a {@link List} object. + */ + public static <E> List<E> getList(Iterable<E> iterable) { + return getList(iterable.iterator()); + } + + /** + * <p>getList.</p> + * + * @param iterator a {@link Collection} object. + * @param <E> a E object. + * @return a {@link List} object. + */ + public static <E> List<E> getList(Iterator<E> iterator) { + List<E> result = Lists.newArrayList(); + while(iterator.hasNext()) { + result.add(iterator.next()); + } + return result; + } + + /** + * <p>getStream.</p> + * + * @param list a {@link Iterable} object. + * @param <E> a E object. + * @return a {@link List} object. + */ + public static <E> Stream<E> getStream(Iterable<E> iterable) { + return getStream(iterable.spliterator()); + } + + public static <E> Stream<E> getStream(Spliterator<E> iterator) { + return StreamSupport.stream(iterator, false); + } + + /** + * <p>getStream.</p> + * + * @param list a {@link Iterable} object. + * @param <E> a E object. + * @return a {@link List} object. + */ + public static <E> E[] toArray(Iterable<E> iterable, IntFunction<E[]> generator) { + return getStream(iterable).toArray(generator); + } + + /** * <p>getList.</p> * @@ -89,16 +144,6 @@ public class Beans { return Arrays.stream(array); } - public static <E> Stream<E> getStream(Iterable<E> iterable) { - if (iterable == null) { - return Stream.empty(); - } - if (iterable instanceof Collection) { - return ((Collection<E>) iterable).stream(); - } - return Streams.stream(iterable); - } - /** * <p>getListWithoutNull.</p> * diff --git a/pom.xml b/pom.xml index 00e88ca84a387d60075ef4f7e8ba0064e73daaae..57c8cb5faf6478ba9f23c47ed095252d4c38b8bd 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ <stringtemplate.version>4.1</stringtemplate.version> <jTextUtilsVersion>0.3.3</jTextUtilsVersion> <lombok.version>1.18.20</lombok.version> - <httpclient.version>4.5.10</httpclient.version> + <httpclient.version>4.5.13</httpclient.version> <nuitonConfigVersion>3.0</nuitonConfigVersion> <nuitonVersionVersion>1.0-rc-2</nuitonVersionVersion> @@ -194,7 +194,7 @@ <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> - <version>3.4</version> + <version>3.12.0</version> </dependency> <dependency> <groupId>org.antlr</groupId> @@ -215,17 +215,12 @@ <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> - <version>1.1.1</version> + <version>1.2</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> - <version>2.6</version> - </dependency> - <dependency> - <groupId>jakarta.mail</groupId> - <artifactId>jakarta.mail-api</artifactId> - <version>${javaMail.version}</version> + <version>2.11.0</version> </dependency> <dependency> <groupId>com.sun.mail</groupId> @@ -236,12 +231,12 @@ <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-collections4</artifactId> - <version>4.0</version> + <version>4.4</version> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> - <version>1.8.3</version> + <version>1.9.4</version> </dependency> <dependency> <groupId>org.nuiton</groupId>