|
7 | 7 | import org.jspecify.annotations.NonNull; |
8 | 8 |
|
9 | 9 | /** |
10 | | - * Interface for interacting with a Hiero network. This interface provides methods for interacting with Hedera accounts, |
11 | | - * like creating and deleting accounts. An implementation of this interface is using an internal account to interact |
12 | | - * with a Hiero network. That account is the account that is used to pay for the transactions that are sent to the |
13 | | - * network and called 'operator account'. |
| 10 | + * Interface for interacting with a Hiero network. This interface provides methods for interacting |
| 11 | + * with Hedera accounts, like creating and deleting accounts. An implementation of this interface is |
| 12 | + * using an internal account to interact with a Hiero network. That account is the account that is |
| 13 | + * used to pay for the transactions that are sent to the network and called 'operator account'. |
14 | 14 | */ |
15 | 15 | public interface AccountClient { |
16 | 16 |
|
17 | | - /** |
18 | | - * Creates a new account. The account is created with an initial balance of 0 hbar. The account is created by the |
19 | | - * operator account. |
20 | | - * |
21 | | - * @return the created account |
22 | | - * @throws HieroException if the account could not be created |
23 | | - */ |
24 | | - @NonNull |
25 | | - default Account createAccount() throws HieroException { |
26 | | - return createAccount(Hbar.ZERO); |
27 | | - } |
| 17 | + /** |
| 18 | + * Creates a new account. The account is created with an initial balance of 0 hbar. The account is |
| 19 | + * created by the operator account. |
| 20 | + * |
| 21 | + * @return the created account |
| 22 | + * @throws HieroException if the account could not be created |
| 23 | + */ |
| 24 | + @NonNull |
| 25 | + default Account createAccount() throws HieroException { |
| 26 | + return createAccount(Hbar.ZERO); |
| 27 | + } |
28 | 28 |
|
29 | | - /** |
30 | | - * Creates a new account with the given initial balance. The account is created by the operator account. |
31 | | - * |
32 | | - * @param initialBalance the initial balance of the account |
33 | | - * @return the created account |
34 | | - * @throws HieroException if the account could not be created |
35 | | - */ |
36 | | - @NonNull |
37 | | - Account createAccount(@NonNull Hbar initialBalance) throws HieroException; |
| 29 | + /** |
| 30 | + * Creates a new account with the given initial balance. The account is created by the operator |
| 31 | + * account. |
| 32 | + * |
| 33 | + * @param initialBalance the initial balance of the account |
| 34 | + * @return the created account |
| 35 | + * @throws HieroException if the account could not be created |
| 36 | + */ |
| 37 | + @NonNull Account createAccount(@NonNull Hbar initialBalance) throws HieroException; |
38 | 38 |
|
39 | | - /** |
40 | | - * Creates a new account with the given initial balance (in HBAR). The account is created by the operator account. |
41 | | - * |
42 | | - * @param initialBalanceInHbar the initial balance of the account in HBAR |
43 | | - * @return the created account |
44 | | - * @throws HieroException if the account could not be created |
45 | | - */ |
46 | | - @NonNull |
47 | | - default Account createAccount(long initialBalanceInHbar) throws HieroException { |
48 | | - if (initialBalanceInHbar < 0) { |
49 | | - throw new IllegalArgumentException("initialBalanceInHbar must be non-negative"); |
50 | | - } |
51 | | - return createAccount(Hbar.from(initialBalanceInHbar)); |
| 39 | + /** |
| 40 | + * Creates a new account with the given initial balance (in HBAR). The account is created by the |
| 41 | + * operator account. |
| 42 | + * |
| 43 | + * @param initialBalanceInHbar the initial balance of the account in HBAR |
| 44 | + * @return the created account |
| 45 | + * @throws HieroException if the account could not be created |
| 46 | + */ |
| 47 | + @NonNull |
| 48 | + default Account createAccount(long initialBalanceInHbar) throws HieroException { |
| 49 | + if (initialBalanceInHbar < 0) { |
| 50 | + throw new IllegalArgumentException("initialBalanceInHbar must be non-negative"); |
52 | 51 | } |
| 52 | + return createAccount(Hbar.from(initialBalanceInHbar)); |
| 53 | + } |
53 | 54 |
|
54 | | - /** |
55 | | - * Deletes the account with the given ID. All fees of that account are transferred to the operator account. |
56 | | - * |
57 | | - * @param account the account to delete |
58 | | - * @throws HieroException if the account could not be deleted |
59 | | - */ |
60 | | - void deleteAccount(@NonNull Account account) throws HieroException; |
| 55 | + /** |
| 56 | + * Deletes the account with the given ID. All fees of that account are transferred to the operator |
| 57 | + * account. |
| 58 | + * |
| 59 | + * @param account the account to delete |
| 60 | + * @throws HieroException if the account could not be deleted |
| 61 | + */ |
| 62 | + void deleteAccount(@NonNull Account account) throws HieroException; |
61 | 63 |
|
62 | | - /** |
63 | | - * Deletes the account with the given ID. All fees of that account are transferred to the given toAccount. |
64 | | - * |
65 | | - * @param account the account to delete |
66 | | - * @param toAccount the account to transfer the fees to |
67 | | - * @throws HieroException if the account could not be deleted |
68 | | - */ |
69 | | - void deleteAccount(@NonNull Account account, @NonNull Account toAccount) throws HieroException; |
| 64 | + /** |
| 65 | + * Deletes the account with the given ID. All fees of that account are transferred to the given |
| 66 | + * toAccount. |
| 67 | + * |
| 68 | + * @param account the account to delete |
| 69 | + * @param toAccount the account to transfer the fees to |
| 70 | + * @throws HieroException if the account could not be deleted |
| 71 | + */ |
| 72 | + void deleteAccount(@NonNull Account account, @NonNull Account toAccount) throws HieroException; |
70 | 73 |
|
71 | | - /** |
72 | | - * Returns the balance of the given account. |
73 | | - * |
74 | | - * @param accountId the ID of the account |
75 | | - * @return the balance of the account |
76 | | - * @throws HieroException if the balance could not be retrieved |
77 | | - */ |
78 | | - @NonNull |
79 | | - Hbar getAccountBalance(@NonNull AccountId accountId) throws HieroException; |
| 74 | + /** |
| 75 | + * Returns the balance of the given account. |
| 76 | + * |
| 77 | + * @param accountId the ID of the account |
| 78 | + * @return the balance of the account |
| 79 | + * @throws HieroException if the balance could not be retrieved |
| 80 | + */ |
| 81 | + @NonNull Hbar getAccountBalance(@NonNull AccountId accountId) throws HieroException; |
80 | 82 |
|
81 | | - /** |
82 | | - * Returns the balance of the given account. |
83 | | - * |
84 | | - * @param accountId the ID of the account |
85 | | - * @return the balance of the account |
86 | | - * @throws HieroException if the balance could not be retrieved |
87 | | - */ |
88 | | - @NonNull |
89 | | - default Hbar getAccountBalance(@NonNull String accountId) throws HieroException { |
90 | | - Objects.requireNonNull(accountId, "newAccountId must not be null"); |
91 | | - return getAccountBalance(AccountId.fromString(accountId)); |
92 | | - } |
| 83 | + /** |
| 84 | + * Returns the balance of the given account. |
| 85 | + * |
| 86 | + * @param accountId the ID of the account |
| 87 | + * @return the balance of the account |
| 88 | + * @throws HieroException if the balance could not be retrieved |
| 89 | + */ |
| 90 | + @NonNull |
| 91 | + default Hbar getAccountBalance(@NonNull String accountId) throws HieroException { |
| 92 | + Objects.requireNonNull(accountId, "newAccountId must not be null"); |
| 93 | + return getAccountBalance(AccountId.fromString(accountId)); |
| 94 | + } |
93 | 95 |
|
94 | | - /** |
95 | | - * Returns the balance of the operator account. |
96 | | - * |
97 | | - * @return the balance of the operator account |
98 | | - * @throws HieroException if the balance could not be retrieved |
99 | | - */ |
100 | | - @NonNull |
101 | | - Hbar getOperatorAccountBalance() throws HieroException; |
| 96 | + /** |
| 97 | + * Returns the balance of the operator account. |
| 98 | + * |
| 99 | + * @return the balance of the operator account |
| 100 | + * @throws HieroException if the balance could not be retrieved |
| 101 | + */ |
| 102 | + @NonNull Hbar getOperatorAccountBalance() throws HieroException; |
102 | 103 | } |
0 commit comments