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 itsattrs
andcontent
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 optimalcontent
- a nullable object, usually a List ofNode
, aString
or aNumber
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionattrs()
Returns the value of theattrs
record component.Returns a list of child WhatsappNodescontent()
Returns the value of thecontent
record component.@NonNull String
Returns the value of thedescription
record component.boolean
Indicates whether some other object is "equal to" this one.fromGenericList(@NonNull List<?> list)
Constructs a list of WhatsappNodes from a generic Liststatic @NonNull Node
Constructs a WhatsappNode from a list where the content is always a JSON Stringint
hashCode()
Returns a hash code value for this object.toString()
Returns a string representation of this record class.
-
Constructor Details
-
Node
public Node(@NonNull @NonNull String description, @NonNull @NonNull Map<String,String> attrs, Object content)Creates an instance of aNode
record class.- Parameters:
description
- the value for thedescription
record componentattrs
- the value for theattrs
record componentcontent
- the value for thecontent
record component
-
-
Method Details
-
fromList
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
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
Returns a list of child WhatsappNodes- Returns:
- a non null list containing WhatsappNodes extracted from this node's content
- Throws:
NullPointerException
- ifcontent
is nullIllegalArgumentException
- ifcontent
is not a List
-
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. -
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. -
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)
. -
description
Returns the value of thedescription
record component.- Returns:
- the value of the
description
record component
-
attrs
Returns the value of theattrs
record component.- Returns:
- the value of the
attrs
record component
-
content
Returns the value of thecontent
record component.- Returns:
- the value of the
content
record component
-