Skip to content

Commit 91ab8e5

Browse files
Merge pull request #149 from OpenElements/cleanup
cleanup: documentation and annotations
2 parents bf092ad + 2a8a542 commit 91ab8e5

File tree

81 files changed

+516
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+516
-270
lines changed

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/FileClient.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ public interface FileClient {
2222
@NonNull
2323
FileId createFile(@NonNull byte[] contents) throws HieroException;
2424

25+
/**
26+
* Create a new file with the given contents and expiration time.
27+
*
28+
* @param contents the contents of the file
29+
* @param expirationTime the expiration time of the file
30+
* @return the ID of the new file
31+
* @throws HieroException if the file could not be created
32+
*/
33+
@NonNull
2534
FileId createFile(@NonNull byte[] contents, @NonNull Instant expirationTime) throws HieroException;
2635

2736
/**
@@ -108,5 +117,6 @@ default void deleteFile(@NonNull String fileId) throws HieroException {
108117
* @return the expiration time of the file
109118
* @throws HieroException if the file could not be checked
110119
*/
120+
@NonNull
111121
Instant getExpirationTime(@NonNull FileId fileId) throws HieroException;
112122
}

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/FungibleTokenClient.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public interface FungibleTokenClient {
2323
* @return the ID of the new token
2424
* @throws HieroException if the token could not be created
2525
*/
26+
@NonNull
2627
TokenId createToken(@NonNull String name, @NonNull String symbol) throws HieroException;
2728

2829
/**
@@ -34,6 +35,7 @@ public interface FungibleTokenClient {
3435
* @return the ID of the new token
3536
* @throws HieroException if the token could not be created
3637
*/
38+
@NonNull
3739
TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull PrivateKey supplyKey)
3840
throws HieroException;
3941

@@ -47,6 +49,7 @@ TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull Priva
4749
* @return the ID of the new token
4850
* @throws HieroException if the token could not be created
4951
*/
52+
@NonNull
5053
default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull String supplyKey)
5154
throws HieroException {
5255
Objects.requireNonNull(name, "name must not be null");
@@ -66,6 +69,7 @@ default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNu
6669
* @return the ID of the new token
6770
* @throws HieroException if the token could not be created
6871
*/
72+
@NonNull
6973
TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull AccountId treasuryAccountId,
7074
@NonNull PrivateKey treasuryKey) throws HieroException;
7175

@@ -80,6 +84,7 @@ TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull Accou
8084
* @return the ID of the new token
8185
* @throws HieroException if the token could not be created
8286
*/
87+
@NonNull
8388
default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull String treasuryAccountId,
8489
@NonNull String treasuryKey) throws HieroException {
8590
Objects.requireNonNull(name, "name must not be null");
@@ -99,6 +104,7 @@ default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNu
99104
* @return the ID of the new token
100105
* @throws HieroException if the token could not be created
101106
*/
107+
@NonNull
102108
default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull Account treasuryAccount)
103109
throws HieroException {
104110
Objects.requireNonNull(name, "name must not be null");
@@ -118,6 +124,7 @@ default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNu
118124
* @return the ID of the new token
119125
* @throws HieroException if the token could not be created
120126
*/
127+
@NonNull
121128
TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull AccountId treasuryAccountId,
122129
@NonNull PrivateKey treasuryKey, @NonNull PrivateKey supplyKey) throws HieroException;
123130

@@ -132,6 +139,7 @@ TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull Accou
132139
* @return the ID of the new token
133140
* @throws HieroException if the token could not be created
134141
*/
142+
@NonNull
135143
default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull String treasuryAccountId,
136144
@NonNull String treasuryKey, @NonNull String supplyKey) throws HieroException {
137145
Objects.requireNonNull(name, "name must not be null");
@@ -153,6 +161,7 @@ default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNu
153161
* @return the ID of the new token
154162
* @throws HieroException if the token could not be created
155163
*/
164+
@NonNull
156165
default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull Account treasuryAccount,
157166
@NonNull PrivateKey supplyKey) throws HieroException {
158167
Objects.requireNonNull(name, "name must not be null");
@@ -172,6 +181,7 @@ default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNu
172181
* @return the ID of the new token
173182
* @throws HieroException if the token could not be created
174183
*/
184+
@NonNull
175185
default TokenId createToken(@NonNull String name, @NonNull String symbol, @NonNull Account treasuryAccount,
176186
@NonNull String supplyKey) throws HieroException {
177187
Objects.requireNonNull(name, "name must not be null");

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/NftClient.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,47 @@ default List<Long> mintNfts(@NonNull String tokenId, @NonNull String supplyKey,
313313
return mintNfts(TokenId.fromString(tokenId), PrivateKey.fromString(supplyKey), metadata);
314314
}
315315

316+
/**
317+
* Burn an NFT.
318+
*
319+
* @param tokenId the ID of the NFT type
320+
* @param serialNumber the serial number of the NFT
321+
* @throws HieroException if the NFT could not be burned
322+
*/
316323
default void burnNft(@NonNull TokenId tokenId, long serialNumber) throws HieroException {
317324
burnNfts(tokenId, Set.of(serialNumber));
318325
}
319326

327+
/**
328+
* Burn an NFT.
329+
*
330+
* @param tokenId the ID of the NFT type
331+
* @param serialNumber the serial number of the NFT
332+
* @param supplyKey the private key of the supply account
333+
* @throws HieroException if the NFT could not be burned
334+
*/
320335
default void burnNft(@NonNull TokenId tokenId, long serialNumber, @NonNull PrivateKey supplyKey)
321336
throws HieroException {
322337
burnNfts(tokenId, Set.of(serialNumber), supplyKey);
323338
}
324339

340+
/**
341+
* Burn NFTs.
342+
*
343+
* @param tokenId the ID of the NFT type
344+
* @param serialNumbers the serial numbers of the NFTs
345+
* @throws HieroException if the NFTs could not be burned
346+
*/
325347
void burnNfts(@NonNull TokenId tokenId, @NonNull Set<Long> serialNumbers) throws HieroException;
326348

349+
/**
350+
* Burn NFTs.
351+
*
352+
* @param tokenId the ID of the NFT type
353+
* @param serialNumbers the serial numbers of the NFTs
354+
* @param supplyKey the private key of the supply account
355+
* @throws HieroException
356+
*/
327357
void burnNfts(@NonNull TokenId tokenId, @NonNull Set<Long> serialNumbers, @NonNull PrivateKey supplyKey)
328358
throws HieroException;
329359

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/config/HieroConfig.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@
1010
import java.util.Set;
1111
import java.util.stream.Collectors;
1212
import org.jspecify.annotations.NonNull;
13-
import org.slf4j.Logger;
14-
import org.slf4j.LoggerFactory;
1513

1614
/**
1715
* Hiero configuration for one network connection.
1816
*/
1917
public interface HieroConfig {
2018

21-
final static Logger log = LoggerFactory.getLogger(HieroConfig.class);
22-
2319
/**
2420
* Returns the operator account for the network.
2521
*
@@ -52,9 +48,19 @@ public interface HieroConfig {
5248
@NonNull
5349
Set<ConsensusNode> getConsensusNodes();
5450

51+
/**
52+
* Returns the chain ID of the network.
53+
*
54+
* @return the chain ID of the network
55+
*/
5556
@NonNull
5657
Optional<Long> chainId();
5758

59+
/**
60+
* Returns the relay URL of the network.
61+
*
62+
* @return the relay URL of the network
63+
*/
5864
@NonNull
5965
Optional<String> relayUrl();
6066

@@ -95,7 +101,7 @@ default Client createClient() {
95101
client.setMirrorNetwork(mirrorNodeAddresses);
96102
client.setOperator(getOperatorAccount().accountId(), getOperatorAccount().privateKey());
97103
return client;
98-
} catch (Exception e) {
104+
} catch (final Exception e) {
99105
throw new IllegalArgumentException("Can not create client for custom network", e);
100106
}
101107
}

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/config/NetworkSettings.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.openelements.hiero.base.config;
22

33
import com.openelements.hiero.base.config.implementation.NetworkSettingsProviderLoader;
4+
import java.util.Objects;
45
import java.util.Optional;
56
import java.util.Set;
67
import org.jspecify.annotations.NonNull;
@@ -68,6 +69,7 @@ public interface NetworkSettings {
6869
*
6970
* @return all available network settings
7071
*/
72+
@NonNull
7173
static Set<NetworkSettings> all() {
7274
return NetworkSettingsProviderLoader.getInstance().all();
7375
}
@@ -78,7 +80,9 @@ static Set<NetworkSettings> all() {
7880
* @param identifier the identifier of the network
7981
* @return the network settings for the given identifier
8082
*/
81-
static Optional<NetworkSettings> forIdentifier(String identifier) {
83+
@NonNull
84+
static Optional<NetworkSettings> forIdentifier(@NonNull String identifier) {
85+
Objects.requireNonNull(identifier, "identifier must not be null");
8286
return NetworkSettingsProviderLoader.getInstance().forIdentifier(identifier);
8387
}
8488
}

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/config/NetworkSettingsProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.openelements.hiero.base.config;
22

33
import java.util.Set;
4+
import org.jspecify.annotations.NonNull;
45

56
/**
67
* SPI interface to provide predefined {@link NetworkSettings} instances. Java SPI functionality is documented at
@@ -13,12 +14,14 @@ public interface NetworkSettingsProvider {
1314
*
1415
* @return the name of the provider
1516
*/
17+
@NonNull
1618
String getName();
1719

1820
/**
1921
* Return a set of {@link NetworkSettings} instances provided by this provider.
2022
*
2123
* @return a set of {@link NetworkSettings} instances
2224
*/
25+
@NonNull
2326
Set<NetworkSettings> createNetworkSettings();
2427
}

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/config/hedera/HederMainnetSettings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
import java.util.Set;
77
import org.jspecify.annotations.NonNull;
88

9+
/**
10+
* Network settings for the Hedera Mainnet.
11+
*/
912
public final class HederMainnetSettings implements NetworkSettings {
1013

14+
/**
15+
* The network identifier.
16+
*/
1117
public static final String NETWORK_IDENTIFIER = "hedera-mainnet";
1218

1319
@Override

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/config/hedera/HederTestnetSettings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
import java.util.Set;
77
import org.jspecify.annotations.NonNull;
88

9+
/**
10+
* Network settings for the Hedera Testnet.
11+
*/
912
public final class HederTestnetSettings implements NetworkSettings {
1013

14+
/**
15+
* The network identifier.
16+
*/
1117
public static final String NETWORK_IDENTIFIER = "hedera-testnet";
1218

1319
@Override

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/config/hedera/HederaNetworkSettingsProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import com.openelements.hiero.base.config.NetworkSettingsProvider;
66
import java.util.Set;
77

8+
/**
9+
* Provides network settings for the Hedera networks.
10+
*/
811
@AutoService(NetworkSettingsProvider.class)
912
public final class HederaNetworkSettingsProvider implements NetworkSettingsProvider {
1013

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/config/implementation/NetworkSettingsProviderLoader.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import org.slf4j.Logger;
1212
import org.slf4j.LoggerFactory;
1313

14+
/**
15+
* Loads network settings from all available {@link NetworkSettingsProvider} implementations by using Java SPI.
16+
*/
1417
public final class NetworkSettingsProviderLoader {
1518

1619
private final static Logger logger = LoggerFactory.getLogger(NetworkSettingsProviderLoader.class);
@@ -41,15 +44,31 @@ private NetworkSettingsProviderLoader() {
4144
this.settings = Collections.unmodifiableSet(loaded);
4245
}
4346

47+
/**
48+
* Returns all loaded network settings.
49+
*
50+
* @return all loaded network settings
51+
*/
4452
public Set<NetworkSettings> all() {
4553
return settings;
4654
}
4755

56+
/**
57+
* Returns the network settings for the given identifier.
58+
*
59+
* @param identifier the network identifier
60+
* @return the network settings for the given identifier
61+
*/
4862
public Optional<NetworkSettings> forIdentifier(String identifier) {
4963
return all().stream().filter(settings -> Objects.equals(settings.getNetworkIdentifier(), identifier))
5064
.findFirst();
5165
}
5266

67+
/**
68+
* Returns the singleton instance of this class.
69+
*
70+
* @return the singleton instance of this class
71+
*/
5372
public static NetworkSettingsProviderLoader getInstance() {
5473
return instance;
5574
}

0 commit comments

Comments
 (0)