java.lang.Object
java.lang.Record
it.auties.whatsapp.model.jid.Jid
- All Implemented Interfaces:
JidProvider
public record Jid(String user, JidServer server, Integer device, Integer agent)
extends Record
implements JidProvider
A model class that represents a jid. This class is only a model, this means that changing its
values will have no real effect on WhatsappWeb's servers.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionagent()Returns the value of theagentrecord component.device()Returns the value of thedevicerecord component.final booleanIndicates whether some other object is "equal to" this one.booleanhasAgent()Returns whether this jid specifies an agentbooleanReturns whether this jid specifies a deviceinthashCode()Returns a hash code value for this object.booleanReturns whether this jid ends with the provided serverbooleanReturns whether this jid is associated with a companion devicebooleanisServerJid(JidServer server) Returns whether this jid is a server jidstatic Jidof(long jid) Constructs a new ContactId for a user from a jidstatic JidConstructs a new ContactId for a user from a jidstatic JidConstructs a new ContactId for a user from a jid and a custom serverstatic JidConstructs a new ContactId for a devicestatic JidofProtobuf(String input) static JidConstructs a new ContactId that represents a serverserver()Returns the value of theserverrecord component.toJid()Returns this object as a jidConverts this jid to a non-formatted phone numberConverts this jid to a signal addresstoString()Converts this jid to a Stringprivate static IntegertryParseAgent(String string) type()Returns the type of this jiduser()Returns the value of theuserrecord component.Converts this jid to a user jidstatic StringwithoutServer(String jid) Parses a nullable jid to the Whatsapp Jid FormatwithServer(JidServer server) Returns a new jid using with a different server
-
Field Details
-
user
The field for theuserrecord component. -
server
The field for theserverrecord component. -
device
The field for thedevicerecord component. -
agent
The field for theagentrecord component.
-
-
Constructor Details
-
Jid
Default constructor
-
-
Method Details
-
ofServer
Constructs a new ContactId that represents a server- Parameters:
server- the non-null custom server- Returns:
- a non-null contact jid
-
ofProtobuf
-
of
Constructs a new ContactId for a user from a jid and a custom server- Parameters:
jid- the nullable jid of the userserver- the non-null custom server- Returns:
- a non-null contact jid
-
withoutServer
Parses a nullable jid to the Whatsapp Jid Format- Parameters:
jid- the nullable jid to parse- Returns:
- null if
jid == null, otherwise a non-null string
-
tryParseAgent
-
ofDevice
Constructs a new ContactId for a device- Parameters:
jid- the nullable jid of the userdevice- the device jid- Returns:
- a non-null contact jid
-
of
Constructs a new ContactId for a user from a jid- Parameters:
jid- the non-null jid of the user- Returns:
- a non-null contact jid
-
of
Constructs a new ContactId for a user from a jid- Parameters:
jid- the non-null jid of the user- Returns:
- a non-null contact jid
-
type
Returns the type of this jid- Returns:
- a non null type
-
isCompanion
public boolean isCompanion()Returns whether this jid is associated with a companion device- Returns:
- true if this jid is a companion
-
hasServer
Returns whether this jid ends with the provided server- Parameters:
server- the server to check against- Returns:
- a boolean
-
isServerJid
Returns whether this jid is a server jid- Parameters:
server- the server to check against- Returns:
- a boolean
-
withServer
Returns a new jid using with a different server- Parameters:
server- the new server- Returns:
- a non-null jid
-
withoutDevice
Converts this jid to a user jid- Returns:
- a non-null jid
-
toPhoneNumber
Converts this jid to a non-formatted phone number- Returns:
- a non-null String
-
toString
Converts this jid to a String -
toSignalAddress
Converts this jid to a signal address- Returns:
- a non-null
SessionAddress
-
toJid
Returns this object as a jid- Specified by:
toJidin interfaceJidProvider- Returns:
- a non-null jid
-
device
Returns the value of thedevicerecord component.- Returns:
- the value of the
devicerecord component
-
hasDevice
public boolean hasDevice()Returns whether this jid specifies a device- Returns:
- a boolean
-
agent
Returns the value of theagentrecord component.- Returns:
- the value of the
agentrecord component
-
hasAgent
public boolean hasAgent()Returns whether this jid specifies an agent- Returns:
- a boolean
-
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
user
Returns the value of theuserrecord component.- Returns:
- the value of the
userrecord component
-
server
Returns the value of theserverrecord component.- Returns:
- the value of the
serverrecord component
-