java.lang.Object
com.hedera.hashgraph.sdk.TopicId
- All Implemented Interfaces:
Comparable<TopicId>
Unique identifier for a topic (used by the consensus service).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanstatic TopicIdfromBytes(byte[] bytes) Create a topic id from a byte array.static TopicIdfromEvmAddress(long shard, long realm, String evmAddress) Constructs a TopicId from shard, realm, and EVM address.(package private) static TopicIdfromProtobuf(TopicID topicId) Create a topic id from a protobuf.static TopicIdfromSolidityAddress(String address) Deprecated.This method is deprecated.static TopicIdfromString(String id) Create a topic id from a string.Extracts the checksum.inthashCode()byte[]toBytes()Extracts a byte array representation.Converts this TopicId to an EVM address string.(package private) TopicIDExtracts a protobuf representing the token id.Deprecated.This method is deprecated.toString()tostringwithchecksum(Client client) Create a string representation that includes the checksum.voidDeprecated.UsevalidateChecksum(Client)instead.voidvalidateChecksum(Client client) Verify that the client has a valid checksum.
-
Field Details
-
shard
@Nonnegative public final long shardThe shard number -
realm
@Nonnegative public final long realmThe realm number -
num
@Nonnegative public final long numThe id number
-
-
Constructor Details
-
TopicId
Deprecated.Constructor.- Parameters:
num- the num part Constructor that uses shard, realm and num should be used instead as shard and realm should not assume 0 value
-
TopicId
public TopicId(@Nonnegative long shard, @Nonnegative long realm, @Nonnegative long num) Constructor.- Parameters:
shard- the shard partrealm- the realm partnum- the num part
-
TopicId
TopicId(@Nonnegative long shard, @Nonnegative long realm, @Nonnegative long num, @Nullable String checksum) Constructor.- Parameters:
shard- the shard partrealm- the realm partnum- the num partchecksum- the checksum
-
-
Method Details
-
fromString
Create a topic id from a string.- Parameters:
id- the string representation- Returns:
- the new topic id
-
fromSolidityAddress
Deprecated.This method is deprecated. UsefromEvmAddress(long, long, String)instead.Retrieve the topic id from a solidity address.- Parameters:
address- a string representing the address- Returns:
- the topic id object
-
fromProtobuf
Create a topic id from a protobuf.- Parameters:
topicId- the protobuf- Returns:
- the new topic id
-
fromBytes
public static TopicId fromBytes(byte[] bytes) throws com.google.protobuf.InvalidProtocolBufferException Create a topic id from a byte array.- Parameters:
bytes- the byte array- Returns:
- the new topic id
- Throws:
com.google.protobuf.InvalidProtocolBufferException- when there is an issue with the protobuf
-
toSolidityAddress
Deprecated.This method is deprecated. UsetoEvmAddress()instead.Extract the solidity address.- Returns:
- the solidity address as a string
-
fromEvmAddress
Constructs a TopicId from shard, realm, and EVM address. The EVM address must be a "long zero address" (first 12 bytes are zero).- Parameters:
shard- the shard numberrealm- the realm numberevmAddress- the EVM address as a hex string- Returns:
- the TopicId object
- Throws:
IllegalArgumentException- if the EVM address is not a valid long zero address
-
toEvmAddress
Converts this TopicId to an EVM address string. Creates a solidity address using shard=0, realm=0, and the file number.- Returns:
- the EVM address as a hex string
-
toProtobuf
TopicID toProtobuf()Extracts a protobuf representing the token id.- Returns:
- the protobuf representation
-
validate
Deprecated.UsevalidateChecksum(Client)instead.- Parameters:
client- to validate against- Throws:
BadEntityIdException- if entity ID is formatted poorly
-
validateChecksum
Verify that the client has a valid checksum.- Parameters:
client- the client to verify- Throws:
BadEntityIdException- if entity ID is formatted poorly
-
getChecksum
Extracts the checksum.- Returns:
- the checksum
-
toBytes
public byte[] toBytes()Extracts a byte array representation.- Returns:
- the byte array representation
-
toString
-
tostringwithchecksum
Create a string representation that includes the checksum.- Parameters:
client- the client- Returns:
- the string representation with the checksum
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<TopicId>
-