-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This code refactoring does not bring any new functionality additions, nor does it bring any breaking changes. The main aspects of the refactoring are as follows: 1. Use Lombok to reduce duplicate code (this also allows us to add `toString`, `hashCode`, and `equals` methods to most classes) 2. Updated some documentation 3. Fixed some warnings. 4. Modified the style of some code.
- Loading branch information
Showing
223 changed files
with
2,471 additions
and
5,830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# .git-blame-ignore-revs | ||
# Add code formatting tool. (#480) | ||
0803b98a7c80e2f68f5bf5652e0eddd99faef455 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,41 @@ | ||
package org.stellar.sdk; | ||
|
||
import java.util.Objects; | ||
import lombok.AllArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
|
||
/** | ||
* Represents an account in Stellar network with it's sequence number. Account object is required to | ||
* Represents an account in Stellar network with its sequence number. Account object is required to | ||
* build a {@link Transaction}. | ||
* | ||
* @see TransactionBuilder | ||
*/ | ||
@Getter | ||
@EqualsAndHashCode | ||
@AllArgsConstructor | ||
public class Account implements TransactionBuilderAccount { | ||
private final String mAccountId; | ||
private Long mSequenceNumber; | ||
|
||
/** | ||
* Class constructor. | ||
* | ||
* @param accountId ID associated with this Account | ||
* @param sequenceNumber Current sequence number of the account (can be obtained using | ||
* java-stellar-sdk or horizon server) | ||
*/ | ||
public Account(@NonNull String accountId, @NonNull Long sequenceNumber) { | ||
mAccountId = accountId; | ||
mSequenceNumber = sequenceNumber; | ||
} | ||
|
||
@Override | ||
public String getAccountId() { | ||
return mAccountId; | ||
} | ||
@NonNull private final String accountId; | ||
@NonNull private Long sequenceNumber; | ||
|
||
@Override | ||
public KeyPair getKeyPair() { | ||
return KeyPair.fromAccountId(mAccountId); | ||
} | ||
|
||
@Override | ||
public Long getSequenceNumber() { | ||
return mSequenceNumber; | ||
return KeyPair.fromAccountId(accountId); | ||
} | ||
|
||
@Override | ||
public void setSequenceNumber(long seqNum) { | ||
mSequenceNumber = seqNum; | ||
sequenceNumber = seqNum; | ||
} | ||
|
||
@Override | ||
public Long getIncrementedSequenceNumber() { | ||
return mSequenceNumber + 1; | ||
return sequenceNumber + 1; | ||
} | ||
|
||
/** Increments sequence number in this object by one. */ | ||
public void incrementSequenceNumber() { | ||
mSequenceNumber++; | ||
} | ||
|
||
public int hashCode() { | ||
return Objects.hash(this.mAccountId, this.mSequenceNumber); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object object) { | ||
if (!(object instanceof Account)) { | ||
return false; | ||
} | ||
|
||
Account other = (Account) object; | ||
return Objects.equals(this.mAccountId, other.mAccountId) | ||
&& Objects.equals(this.mSequenceNumber, other.mSequenceNumber); | ||
sequenceNumber++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.