Module whatsapp4j

Record Class Node

java.lang.Object
java.lang.Record
it.auties.whatsapp4j.protobuf.model.Node
Record Components:
description - a non null String that describes the data that this object holds in its attrs and content
attrs - a non null Map of strings that describe additional information related to the content of this object or an encoded object when sending a message a protobuf object is not optimal
content - a nullable object, usually a List of Node, a String or a Number

public record Node(@NonNull String description, @NonNull Map<String,String> attrs, Object content) extends Record
An immutable model class that represents the primary unit used by WhatsappWeb's WebSocket to communicate with the client.
  • Constructor Details

    • Node

      public Node(@NonNull @NonNull String description, @NonNull @NonNull Map<String,String> attrs, Object content)
      Creates an instance of a Node record class.
      Parameters:
      description - the value for the description record component
      attrs - the value for the attrs record component
      content - the value for the content record component
  • Method Details

    • fromList

      @NonNull public static @NonNull Node fromList(@NonNull @NonNull List<?> list)
      Constructs a WhatsappNode from a list where the content is always a JSON String
      Parameters:
      list - the generic list to parse
      Returns:
      a non null list containing only objects from list of type WhatsappNode
    • fromGenericList

      @NonNull public static @NonNull List<Node> fromGenericList(@NonNull @NonNull List<?> list)
      Constructs a list of WhatsappNodes from a generic List
      Parameters:
      list - the generic list to parse
      Returns:
      a non null list containing only objects from list of type WhatsappNode
    • childNodes

      @NonNull public @NonNull List<Node> childNodes()
      Returns a list of child WhatsappNodes
      Returns:
      a non null list containing WhatsappNodes extracted from this node's content
      Throws:
      NullPointerException - if content is null
      IllegalArgumentException - if content is not a List
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • description

      @NonNull public @NonNull String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • attrs

      @NonNull public @NonNull Map<String,String> attrs()
      Returns the value of the attrs record component.
      Returns:
      the value of the attrs record component
    • content

      public Object content()
      Returns the value of the content record component.
      Returns:
      the value of the content record component