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().
  • Constructor Details

  • Method Details

    • ofJid

      public static Contact ofJid(@NonNull @NonNull ContactJid jid)
      Constructs a new Contact from a provided jid
      Parameters:
      jid - the non-null jid
      Returns:
      a non-null Contact
    • name

      public String name()
      Returns the best name available for this contact
      Returns:
      a non-null String
    • lastSeen

      public Optional<ZonedDateTime> 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
    • equals

      public boolean equals(Object other)
      Checks if this contact is equal to another contact
      Overrides:
      equals in class Object
      Parameters:
      other - the contact
      Returns:
      a boolean
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toJid

      @NonNull public @NonNull ContactJid toJid()
      Returns this object as a jid
      Specified by:
      toJid in interface ContactJidProvider
      Returns:
      a non-null jid
    • builder

      public static Contact.ContactBuilder builder()
    • jid

      @NonNull public @NonNull ContactJid jid()
      The non-null unique jid used to identify this contact
    • chosenName

      public String 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

      public String fullName()
      The nullable name associated with this contact on the phone connected with Whatsapp
    • shortName

      public String 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

      public ContactStatus 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, use Whatsapp.subscribeToPresence(ContactJidProvider).
    • blocked

      public boolean blocked()
      Whether this contact is blocked
    • chosenName

      public Contact chosenName(String 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

      public Contact fullName(String fullName)
      The nullable name associated with this contact on the phone connected with Whatsapp
      Returns:
      this.
    • shortName

      public Contact shortName(String 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

      public Contact lastKnownPresence(ContactStatus 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, use Whatsapp.subscribeToPresence(ContactJidProvider).
      Returns:
      this.
    • lastSeen

      public Contact lastSeen(ZonedDateTime 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

      public Contact blocked(boolean blocked)
      Whether this contact is blocked
      Returns:
      this.
    • toString

      public String toString()
      Overrides:
      toString in class Object