java.lang.Object
java.lang.Record
it.auties.whatsapp.model.node.Attributes
- Record Components:
toMap- the non-null wrapped map
A utility class that wraps a map and provides easy methods to interact with its content
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LinkedHashMap<String, Object> The field for thetoMaprecord component. -
Constructor Summary
ConstructorsConstructorDescriptionAttributes(LinkedHashMap<String, Object> toMap) Creates an instance of aAttributesrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Copies this objectfinal booleanIndicates whether some other object is "equal to" this one.<T> Optional<T> Gets a value by key in the wrapped map<T> TGets a value by key in the wrapped mapbooleangetBoolean(String key) Gets a value as a boolean by key in the wrapped mapintGets a value as an int by key in the wrapped maplongGets a value as a long by key in the wrapped mapgetNullableInt(String key) Gets a nullable value as an int by key in the wrapped mapgetNullableLong(String key) Gets a nullable value as a long by key in the wrapped mapgetNullableString(String key) Gets a nullable value as a string by key in the wrapped mapgetOptionalInt(String key) Gets a value as an int by key in the wrapped mapgetOptionalJid(String key) Gets an optional value as a ContactJid by key in the wrapped mapgetOptionalLong(String key) Gets a value as a long by key in the wrapped mapgetOptionalString(String key) Gets an optional value as a string by key in the wrapped mapintgetRequiredInt(String key) Gets a non-null value as an int by key in the wrapped map.getRequiredJid(String key) Gets a required value as a ContactJid by key in the wrapped maplonggetRequiredLong(String key) Gets a non-null value as a long by key in the wrapped map.getRequiredString(String key) Gets a non-null value as a string by key in the wrapped map.Gets a non-null value as a string by key in the wrapped map.Gets a value as a string by key in the wrapped map.final inthashCode()Returns a hash code value for this object.booleanChecks whether a non-null key whatsappOldEligible in this mapbooleanChecks whether a non-null key whatsappOldEligible in this map and has the provided valuebooleanisEmpty()Returns whether this object is emptystatic AttributesConstructs a new map using the non-null provided entriesstatic AttributesConstructs a new map using the provided non-null mapstatic AttributesofNullable(Map<String, ?> map) Constructs a new map using the provided nullable mapprivate booleanprivate intprivate Jidprivate longInserts a key-value pair in the wrapped mapInserts a key-value pair in the wrapped mapput(String key, Object value, BooleanSupplier... conditions) Inserts a key-value pair in the wrapped mapfinal <T> AttributesInserts a key-value pair in the wrapped mapputAll(Collection<? extends Map.Entry<String, ?>> entries) final AttributestoMap()Returns the value of thetoMaprecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
toMap
The field for thetoMaprecord component.
-
-
Constructor Details
-
Attributes
Creates an instance of aAttributesrecord class.- Parameters:
toMap- the value for thetoMaprecord component
-
-
Method Details
-
of
Constructs a new map using the non-null provided entries- Parameters:
entries- the non-null entries- Returns:
- a new instance of Attributes
-
ofNullable
Constructs a new map using the provided nullable map- Parameters:
map- the nullable existing map- Returns:
- a new instance of Attributes
-
of
Constructs a new map using the provided non-null map- Parameters:
map- the non-null existing map- Returns:
- a new instance of Attributes
-
hasKey
Checks whether a non-null key whatsappOldEligible in this map- Parameters:
key- the non-null key- Returns:
- a boolean
-
hasValue
Checks whether a non-null key whatsappOldEligible in this map and has the provided value- Parameters:
key- the non-null keyvalue- the nullable value to check against- Returns:
- a boolean
-
put
@SafeVarargs public final <T> Attributes put(String key, T value, Function<T, Boolean>... conditions) Inserts a key-value pair in the wrapped map- Type Parameters:
T- the type of the value- Parameters:
key- the non-null keyvalue- the nullable valueconditions- the non-null conditions that must be met to insert the value- Returns:
- the calling instance
-
put
Inserts a key-value pair in the wrapped map- Parameters:
key- the non-null keyvalue- the nullable valueconditions- the non-null conditions that must be met to insert the value- Returns:
- the calling instance
-
put
Inserts a key-value pair in the wrapped map- Parameters:
key- the non-null keyvalue- the nullable valuecondition- the condition that must be met to insert the value- Returns:
- the calling instance
-
put
Inserts a key-value pair in the wrapped map- Parameters:
key- the non-null keyvalue- the nullable value- Returns:
- the calling instance
-
get
Gets a value by key in the wrapped map- Type Parameters:
T- the type of the value that is returned- Parameters:
key- the non-null keydefaultValue- the non-null default valueclazz- the non-null type of the value that is returned- Returns:
- the non-null value
-
get
Gets a value by key in the wrapped map- Type Parameters:
T- the type of the value that is returned- Parameters:
key- the non-null keyclazz- the non-null type of the value that is returned- Returns:
- the non-null value
-
getInt
Gets a value as an int by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- the non-null value
-
getOptionalInt
Gets a value as an int by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- the non-null value
-
parseInt
-
getLong
Gets a value as a long by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- the non-null value
-
getOptionalLong
Gets a value as a long by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- the non-null value
-
parseLong
-
getString
Gets a non-null value as a string by key in the wrapped map. If the key doesn't exist, unknown is returned.- Parameters:
key- the non-null key- Returns:
- the non-null value
-
getString
Gets a value as a string by key in the wrapped map. If the value is null, defaultValue is returned.- Parameters:
key- the non-null key- Returns:
- a non-null string
-
getNullableString
Gets a nullable value as a string by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- the nullable value
-
getNullableInt
Gets a nullable value as an int by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- the nullable value
-
getNullableLong
Gets a nullable value as a long by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- the nullable value
-
getRequiredString
Gets a non-null value as a string by key in the wrapped map. Throws an exception if the key doesn't exist.- Parameters:
key- the non-null key- Returns:
- the non-null value
-
getRequiredInt
Gets a non-null value as an int by key in the wrapped map. Throws an exception if the key doesn't exist.- Parameters:
key- the non-null key- Returns:
- the non-null value
-
getRequiredLong
Gets a non-null value as a long by key in the wrapped map. Throws an exception if the key doesn't exist.- Parameters:
key- the non-null key- Returns:
- the non-null value
-
getOptionalString
Gets an optional value as a string by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- a non-null optional
-
getBoolean
Gets a value as a boolean by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- a boolean
-
parseBool
-
getOptionalJid
Gets an optional value as a ContactJid by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- a non-null optional
-
getRequiredJid
Gets a required value as a ContactJid by key in the wrapped map- Parameters:
key- the non-null key- Returns:
- a non-null value
-
parseJid
-
copy
Copies this object- Returns:
- a non-null instance
-
isEmpty
public boolean isEmpty()Returns whether this object is empty- Returns:
- a boolean
-
putAll
-
putAll
-
putAll
-
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). -
toMap
Returns the value of thetoMaprecord component.- Returns:
- the value of the
toMaprecord component
-