Class Controller<T extends Controller<T>>

java.lang.Object
it.auties.whatsapp.controller.Controller<T>
All Implemented Interfaces:
it.auties.protobuf.model.ProtobufMessage, it.auties.protobuf.model.ProtobufObject
Direct Known Subclasses:
Keys, Store

public abstract sealed class Controller<T extends Controller<T>> extends Object implements it.auties.protobuf.model.ProtobufMessage permits Store, Keys
This interface represents is implemented by all WhatsappWeb4J's controllers. It provides an easy way to store IDs and serialize said class.
  • Field Details

    • uuid

      protected final UUID uuid
      The id of this controller
    • phoneNumber

      private PhoneNumber phoneNumber
      The phone number of the associated companion
    • serializer

      protected ControllerSerializer serializer
      The serializer instance to use
    • clientType

      protected final ClientType clientType
      The client type
    • alias

      protected final Collection<String> alias
      A list of alias for the controller, can be used in place of UUID1
  • Constructor Details

  • Method Details

    • serialize

      public abstract void serialize(boolean async)
      Serializes this object
      Parameters:
      async - whether the operation should be executed asynchronously
    • dispose

      public abstract void dispose()
      Disposes this object
    • uuid

      public UUID uuid()
    • clientType

      public ClientType clientType()
    • phoneNumber

      public Optional<PhoneNumber> phoneNumber()
      Returns the phone number of this controller
      Returns:
      an optional
    • setPhoneNumber

      public T setPhoneNumber(PhoneNumber phoneNumber)
      Sets the phone number used by this session
      Returns:
      the same instance
    • serializer

      public ControllerSerializer serializer()
      Returns the serializer
      Returns:
      a non-null serializer
    • setSerializer

      public T setSerializer(ControllerSerializer serializer)
      Sets the serializer of this controller
      Parameters:
      serializer - a serializer
      Returns:
      the same instance
    • alias

      public Collection<String> alias()
      Returns an immutable collection of alias
      Returns:
      an immutable collection
    • addAlias

      public void addAlias(String entry)
      Adds an alias to this controller
      Parameters:
      entry - the non-null alias to add
    • removeAlias

      public void removeAlias(String entry)
      Removes an alias to this controller
      Parameters:
      entry - the non-null alias to remove
    • removeAlias

      public void removeAlias()
      Removes all alias from this controller
    • toJson

      public String toJson()
      Converts this controller to a json. Useful when debugging.
      Returns:
      a non-null string
    • deleteSession

      public void deleteSession()
      Deletes the current session