java.lang.Object
it.auties.whatsapp.model.contact.Contact
- All Implemented Interfaces:
it.auties.protobuf.base.ProtobufMessage
,ContactJidProvider
public final class Contact
extends Object
implements it.auties.protobuf.base.ProtobufMessage, ContactJidProvider
A model class that represents a Contact. This class is only a model, this means that changing its
values will have no real effect on WhatsappWeb's servers. This class also offers a builder,
accessible using
builder()
.-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionContact
(@NonNull ContactJid jid, String chosenName, String fullName, String shortName, ContactStatus lastKnownPresence, ZonedDateTime lastSeen, boolean blocked) -
Method Summary
Modifier and TypeMethodDescriptionboolean
blocked()
Whether this contact is blockedblocked
(boolean blocked) Whether this contact is blockedstatic Contact.ContactBuilder
builder()
The nullable name specified by this contact when he created a Whatsapp account.chosenName
(String chosenName) The nullable name specified by this contact when he created a Whatsapp account.boolean
Checks if this contact is equal to another contactfullName()
The nullable name associated with this contact on the phone connected with WhatsappThe nullable name associated with this contact on the phone connected with Whatsappint
hashCode()
@NonNull ContactJid
jid()
The non-null unique jid used to identify this contactThe nullable last known presence of this contact.lastKnownPresence
(ContactStatus lastKnownPresence) The nullable last known presence of this contact.lastSeen()
Returns an optional object wrapping the last seconds this contact was seen.lastSeen
(ZonedDateTime lastSeen) The nullable last seconds this contact was seen available.name()
Returns the best name available for this contactstatic Contact
ofJid
(@NonNull ContactJid jid) Constructs a new Contact from a provided jidThe nullable short name associated with this contact on the phone connected with Whatsapp If a name is available, theoretically, also a short name should beThe nullable short name associated with this contact on the phone connected with Whatsapp If a name is available, theoretically, also a short name should be@NonNull ContactJid
toJid()
Returns this object as a jidtoString()
-
Constructor Details
-
Contact
public Contact(@NonNull @NonNull ContactJid jid, String chosenName, String fullName, String shortName, ContactStatus lastKnownPresence, ZonedDateTime lastSeen, boolean blocked)
-
-
Method Details
-
ofJid
Constructs a new Contact from a provided jid- Parameters:
jid
- the non-null jid- Returns:
- a non-null Contact
-
name
Returns the best name available for this contact- Returns:
- a non-null String
-
lastSeen
Returns an optional object wrapping the last seconds this contact was seen. If this information isn't available, an empty optional is returned.- Returns:
- an optional object wrapping the last seconds this contact was seen available
-
hashCode
public int hashCode() -
equals
Checks if this contact is equal to another contact -
toJid
Returns this object as a jid- Specified by:
toJid
in interfaceContactJidProvider
- Returns:
- a non-null jid
-
builder
-
jid
The non-null unique jid used to identify this contact -
chosenName
The nullable name specified by this contact when he created a Whatsapp account. Theoretically, it should not be possible for this field to be null as it's required when registering for Whatsapp. Though it looks that it can be removed later, so it's nullable. -
fullName
The nullable name associated with this contact on the phone connected with Whatsapp -
shortName
The nullable short name associated with this contact on the phone connected with Whatsapp If a name is available, theoretically, also a short name should be -
lastKnownPresence
The nullable last known presence of this contact. This field is associated only with the presence of this contact in the corresponding conversation. If, for example, this contact is composing, recording or paused in a group this field will not be affected. Instead,Chat.presences()
should be used. By default, Whatsapp will not send updates about a contact's status unless they send a message or are in the recent contacts. To force Whatsapp to send updates, useWhatsapp.subscribeToPresence(ContactJidProvider)
. -
blocked
public boolean blocked()Whether this contact is blocked -
chosenName
The nullable name specified by this contact when he created a Whatsapp account. Theoretically, it should not be possible for this field to be null as it's required when registering for Whatsapp. Though it looks that it can be removed later, so it's nullable.- Returns:
this
.
-
fullName
The nullable name associated with this contact on the phone connected with Whatsapp- Returns:
this
.
-
shortName
The nullable short name associated with this contact on the phone connected with Whatsapp If a name is available, theoretically, also a short name should be- Returns:
this
.
-
lastKnownPresence
The nullable last known presence of this contact. This field is associated only with the presence of this contact in the corresponding conversation. If, for example, this contact is composing, recording or paused in a group this field will not be affected. Instead,Chat.presences()
should be used. By default, Whatsapp will not send updates about a contact's status unless they send a message or are in the recent contacts. To force Whatsapp to send updates, useWhatsapp.subscribeToPresence(ContactJidProvider)
.- Returns:
this
.
-
lastSeen
The nullable last seconds this contact was seen available. Any contact can decide to hide this information in their privacy settings.- Returns:
this
.
-
blocked
Whether this contact is blocked- Returns:
this
.
-
toString
-