documentation

This commit is contained in:
pinpong
2017-02-13 18:06:23 +01:00
parent 878f5e9f95
commit 6000f702d6
8 changed files with 370 additions and 5 deletions
@@ -20,6 +20,11 @@ public abstract class AbstractResponse {
this.duration = duration;
}
/**
* Returns a String that represents this object.
*
* @return Returns a string representation of this object.
*/
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
+49 -1
View File
@@ -20,27 +20,55 @@ public class Bundle implements Comparable<Bundle> {
private int length;
/**
* Initializes a new instance of the Bundle class without transactions.
*/
public Bundle() {
this(new ArrayList<Transaction>(), 0);
}
/**
* Initializes a new instance of the Bundle class.
*/
public Bundle(List<Transaction> transactions, int length) {
this.transactions = transactions;
this.length = length;
}
/**
* Gets the transactions
*
* @return transactions The transactions.
*/
public List<Transaction> getTransactions() {
return transactions;
}
/**
* Gets the length of the bundle
*
* @return length The length.
*/
public int getLength() {
return length;
}
/**
* Sets the length of the bundle
* @param length The length.
*/
public void setLength(int length) {
this.length = length;
}
/**
* Adds a bundle entry
* @param signatureMessageLength Length of the signature message.
* @param address The address.
* @param value The value.
* @param tag The tag.
* @param timestamp The timestamp.
*/
public void addEntry(int signatureMessageLength, String address, long value, String tag, long timestamp) {
if (getTransactions() == null) {
this.transactions = new ArrayList<>(getTransactions());
@@ -52,6 +80,10 @@ public class Bundle implements Comparable<Bundle> {
}
}
/**
* Finalizes the bundle using the specified curl implementation
* @param customCurl The custom curl.
*/
public void finalize(ICurl customCurl) {
ICurl curl = customCurl == null ? new JCurl() : customCurl;
@@ -81,7 +113,10 @@ public class Bundle implements Comparable<Bundle> {
}
}
/**
* Adds the trytes.
* @param signatureFragments The signature fragments.
*/
public void addTrytes(List<String> signatureFragments) {
String emptySignatureFragment = "";
String emptyHash = EMPTY_HASH;
@@ -103,6 +138,12 @@ public class Bundle implements Comparable<Bundle> {
}
}
/**
* Normalized the bundle.
* @param bundleHash The bundle hash.
* @return normalizedBundle A normalized bundle hash.
*/
public int[] normalizedBundle(String bundleHash) {
int[] normalizedBundle = new int[81];
@@ -141,6 +182,13 @@ public class Bundle implements Comparable<Bundle> {
return normalizedBundle;
}
/**
* Compares the current object with another object of the same type.
* @param o An object to compare with this object.
* @return A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the <paramref name="other" /> parameter.Zero This object is equal to <paramref name="other" />. Greater than zero This object is greater than <paramref name="other" />.
*/
@Override
public int compareTo(Bundle o) {
return Long.compare(Long.parseLong(this.getTransactions().get(0).getTimestamp()), Long.parseLong(o.getTransactions().get(0).getTimestamp()));
+42 -1
View File
@@ -8,12 +8,15 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author Adrian
**/
public class Input {
private String address;
private long balance;
private int keyIndex;
private int security;
/**
* Initializes a new instance of the Input class.
*/
public Input(String address, long balance, int keyIndex, int security) {
this.address = address;
this.balance = balance;
@@ -22,39 +25,77 @@ public class Input {
}
/**
* Returns a String that represents this object.
*
* @return Returns a string representation of this object.
*/
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
/**
* Get the address.
*
* @return address The address.
*/
public String getAddress() {
return address;
}
/**
* Get the address.
* @param address The address.
*/
public void setAddress(String address) {
this.address = address;
}
/**
* Get the balance.
* @return address The balance.
*/
public long getBalance() {
return balance;
}
/**
* Get the balance.
* @param balance The balance.
*/
public void setBalance(long balance) {
this.balance = balance;
}
/**
* Get the keyIndex.
* @return keyIndex The keyIndex.
*/
public int getKeyIndex() {
return keyIndex;
}
/**
* Get the keyIndex.
* @param keyIndex The keyIndex.
*/
public void setKeyIndex(int keyIndex) {
this.keyIndex = keyIndex;
}
/**
* Get the security.
* @return security The security.
*/
public int getSecurity() {
return security;
}
/**
* Get the security.
* @param security The security.
*/
public void setSecurity(int security) {
this.security = security;
}
+26
View File
@@ -9,31 +9,57 @@ import java.util.List;
* @author Adrian
**/
public class Inputs {
private List<Input> inputsList;
private long totalBalance;
/**
* Initializes a new instance of the Input class.
*/
public Inputs(List<Input> inputsList, long totalBalance) {
this.inputsList = inputsList;
this.totalBalance = totalBalance;
}
/**
* Returns a Json Object that represents this object.
*
* @return Returns a string representation of this object.
*/
@Override
public String toString() {
return new Gson().toJson(this);
}
/**
* Get the input list.
*
* @return inputList The input list.
*/
public List<Input> getInputsList() {
return inputsList;
}
/**
* Set the input list.
* @param inputsList The input list.
*/
public void setInputsList(List<Input> inputsList) {
inputsList = inputsList;
}
/**
* Get the total balance.
* @return totalBalance The total balance.
*/
public long getTotalBalance() {
return totalBalance;
}
/**
* Set the total balance.
* @param totalBalance The total balance.
*/
public void setTotalBalance(long totalBalance) {
this.totalBalance = totalBalance;
}
+21
View File
@@ -11,6 +11,9 @@ public class Neighbor {
private Integer numberOfInvalidTransactions;
private Integer numberOfNewTransactions;
/**
* Initializes a new instance of the Neighbor class.
*/
public Neighbor(String address, Integer numberOfAllTransactions, Integer numberOfInvalidTransactions, Integer numberOfNewTransactions) {
this.address = address;
this.numberOfAllTransactions = numberOfAllTransactions;
@@ -18,18 +21,36 @@ public class Neighbor {
this.numberOfNewTransactions = numberOfNewTransactions;
}
/**
* Get the address.
*
* @return address The address.
*/
public String getAddress() {
return address;
}
/**
* Get the number of all transactions.
*
* @return numberOfAllTransactions The number of all transactions.
*/
public Integer getNumberOfAllTransactions() {
return numberOfAllTransactions;
}
/**
* Get the number of invalid transactions.
* @return numberOfInvalidTransactions The number of invalid transactions.
*/
public Integer getNumberOfInvalidTransactions() {
return numberOfInvalidTransactions;
}
/**
* Get the number of nwe transactions.
* @return numberOfNewTransactions The number of new transactions.
*/
public Integer getNumberOfNewTransactions() {
return numberOfNewTransactions;
}
+23 -2
View File
@@ -9,25 +9,46 @@ import java.util.List;
**/
public class Signature {
String address;
List<String> signatureFragments;
private String address;
private List<String> signatureFragments;
/**
* Initializes a new instance of the Signature class.
*/
public Signature() {
this.signatureFragments = new ArrayList<>();
}
/**
* Get the address.
*
* @return address The address.
*/
public String getAddress() {
return address;
}
/**
* Set the address.
*
* @param address The address.
*/
public void setAddress(String address) {
this.address = address;
}
/**
* Get the signatureFragments.
* @return signatureFragments The signatureFragments.
*/
public List<String> getSignatureFragments() {
return signatureFragments;
}
/**
* Set the signatureFragments.
* @param signatureFragments The signatureFragments.
*/
public void setSignatureFragments(List<String> signatureFragments) {
this.signatureFragments = signatureFragments;
}
+136 -1
View File
@@ -16,6 +16,7 @@ import java.util.Arrays;
* @author pinpong
*/
public class Transaction {
private static final Logger log = LoggerFactory.getLogger(Transaction.class);
private ICurl customCurl;
@@ -33,23 +34,38 @@ public class Transaction {
private String nonce;
private Boolean persistence;
/**
* Initializes a new instance of the Signature class.
*/
public Transaction(ICurl curl) {
customCurl = curl;
}
/**
* Initializes a new instance of the Signature class.
*/
public Transaction() {
customCurl = null;
}
/**
* Initializes a new instance of the Signature class.
*/
public Transaction(String trytes) {
transactionObject(trytes);
}
/**
* Initializes a new instance of the Signature class.
*/
public Transaction(String trytes, ICurl customCurl) {
transactionObject(trytes);
this.customCurl = customCurl;
}
/**
* Initializes a new instance of the Signature class.
*/
public Transaction(String signatureFragments, String currentIndex, String lastIndex, String nonce, String hash, String tag, String timestamp, String trunkTransaction, String branchTransaction, String address, String value, String bundle) {
this.hash = hash;
@@ -66,7 +82,9 @@ public class Transaction {
this.nonce = nonce;
}
/**
* Initializes a new instance of the Signature class.
*/
public Transaction(String address, String value, String tag, String timestamp) {
this.address = address;
this.value = value;
@@ -74,111 +92,221 @@ public class Transaction {
this.timestamp = timestamp;
}
/**
* Returns a String that represents this object.
*
* @return Returns a string representation of this object.
*/
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
/**
* Get the hash.
*
* @return hash The hash.
*/
public String getHash() {
return hash;
}
/**
* Set the hash.
* @param hash The hash.
*/
public void setHash(String hash) {
this.hash = hash;
}
/**
* Get the signature fragments.
* @return signatureFragments The signature fragments.
*/
public String getSignatureFragments() {
return signatureFragments;
}
/**
* Set the signature fragments.
* @param signatureFragments The signature fragments.
*/
public String setSignatureFragments(String signatureFragments) {
return this.signatureFragments = signatureFragments;
}
/**
* Get the address.
* @return address The address.
*/
public String getAddress() {
return address;
}
/**
* Set the address.
* @param address The address.
*/
public void setAddress(String address) {
this.address = address;
}
/**
* Get the value.
* @return value The value.
*/
public String getValue() {
return value;
}
/**
* Set the value.
* @param value The value.
*/
public void setValue(String value) {
this.value = value;
}
/**
* Get the tag.
* @return tag The tag.
*/
public String getTag() {
return tag;
}
/**
* Set the tag.
* @param tag The tag.
*/
public void setTag(String tag) {
this.tag = tag;
}
/**
* Get the timestamp.
* @return timestamp The timestamp.
*/
public String getTimestamp() {
return timestamp;
}
/**
* Set the timestamp.
* @param timestamp The timestamp.
*/
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
/**
* Get the current index.
* @return currentIndex The current index.
*/
public String getCurrentIndex() {
return currentIndex;
}
/**
* Set the current index.
* @param currentIndex The current index.
*/
public String setCurrentIndex(String currentIndex) {
return this.currentIndex = currentIndex;
}
/**
* Get the last index.
* @return lastIndex The last index.
*/
public String getLastIndex() {
return lastIndex;
}
/**
* Set the last index.
* @param lastIndex The last index.
*/
public String setLastIndex(String lastIndex) {
return this.lastIndex = lastIndex;
}
/**
* Get the bundle.
* @return bundle The bundle.
*/
public String getBundle() {
return bundle;
}
/**
* Set the bundle.
* @param bundle The bundle.
*/
public void setBundle(String bundle) {
this.bundle = bundle;
}
/**
* Get the trunk transaction.
* @return trunkTransaction The trunk transaction.
*/
public String getTrunkTransaction() {
return trunkTransaction;
}
/**
* Set the trunk transaction.
* @param trunkTransaction The trunk transaction.
*/
public void setTrunkTransaction(String trunkTransaction) {
this.trunkTransaction = trunkTransaction;
}
/**
* Get the branch transaction.
* @return branchTransaction The branch transaction.
*/
public String getBranchTransaction() {
return branchTransaction;
}
/**
* Set the branch transaction.
* @param branchTransaction The branch transaction.
*/
public void setBranchTransaction(String branchTransaction) {
this.branchTransaction = branchTransaction;
}
/**
* Get the nonce.
* @return nonce The nonce.
*/
public String getNonce() {
return nonce;
}
/**
* Set the nonce.
* @param nonce The trunk nonce.
*/
public void setNonce(String nonce) {
this.nonce = nonce;
}
/**
* Get the persistence.
* @return persistence The persistence.
*/
public Boolean getPersistence() {
return persistence;
}
/**
* Set the persistence.
* @param persistence The persistence.
*/
public void setPersistence(Boolean persistence) {
this.persistence = persistence;
}
@@ -187,6 +315,10 @@ public class Transaction {
return obj != null && ((Transaction) obj).getHash().equals(this.getHash());
}
/**
* Converts the transaction to the corresponding trytes representation
*/
public String toTrytes() {
int[] valueTrits = Converter.trits(this.getValue(), 81);
@@ -212,6 +344,9 @@ public class Transaction {
+ this.getNonce();
}
/**
* Initializes a new instance of the Signature class.
*/
public void transactionObject(final String trytes) {
if (StringUtils.isEmpty(trytes)) {
+68
View File
@@ -16,6 +16,9 @@ public class Transfer {
private String message;
private String tag;
/**
* Initializes a new instance of the Transfer class.
*/
public Transfer(String timestamp, String address, String hash, Boolean persistence, long value, String message,
String tag) {
this.timestamp = timestamp;
@@ -28,6 +31,9 @@ public class Transfer {
}
/**
* Initializes a new instance of the Transfer class.
*/
public Transfer(String address, long value, String message, String tag) {
this.address = address;
this.value = value;
@@ -35,63 +41,125 @@ public class Transfer {
this.tag = tag;
}
/**
* Returns a Json Object that represents this object.
*
* @return Returns a string representation of this object.
*/
@Override
public String toString() {
return new Gson().toJson(this);
}
/**
* Get the address.
*
* @return address The address.
*/
public String getAddress() {
return address;
}
/**
* Set the address
* @param address The address.
*/
public void setAddress(String address) {
this.address = address;
}
/**
* Get the hash.
* @return hash The hash.
*/
public String getHash() {
return hash;
}
/**
* Set the hash
* @param hash The hash.
*/
public void setHash(String hash) {
this.hash = hash;
}
/**
* Get the persistence.
* @return persistence The persistence.
*/
public Boolean getPersistence() {
return persistence;
}
/**
* Set the persistence
* @param persistence The persistence.
*/
public void setPersistence(Boolean persistence) {
this.persistence = persistence;
}
/**
* Get the timestamp.
* @return timestamp The timestamp.
*/
public String getTimestamp() {
return timestamp;
}
/**
* Set the timestamp
* @param timestamp The timestamp.
*/
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
/**
* Get the value.
* @return value The value.
*/
public long getValue() {
return value;
}
/**
* Set the value
* @param value The value.
*/
public void setValue(long value) {
this.value = value;
}
/**
* Get the message.
* @return message The message.
*/
public String getMessage() {
return message;
}
/**
* Set the message
* @param message The message.
*/
public void setMessage(String message) {
this.message = message;
}
/**
* Get the tag.
* @return tag The tag.
*/
public String getTag() {
return tag;
}
/**
* Set the tag
* @param tag The tag.
*/
public void setTag(String tag) {
this.tag = tag;
}