Record Class NameValuePair<V>

java.lang.Object
java.lang.Record
org.tquadrat.foundation.lang.NameValuePair<V>
Type Parameters:
V - The type of the value.
Record Components:
name - The name; may not be null, and it may not be empty.
value - The value; can be null.

@ClassVersion(sourceVersion="$Id: NameValuePair.java 1119 2024-03-16 09:03:57Z tquadrat $") @API(status=STABLE, since="0.1.0") public record NameValuePair<V>(String name, V value) extends Record
An implementation of a name-value-pair.
Author:
Thomas Thrien (thomas.thrien@tquadrat.org)
Version:
$Id: NameValuePair.java 1119 2024-03-16 09:03:57Z tquadrat $
Since:
0.1.0
UML Diagram
UML Diagram for "org.tquadrat.foundation.lang.NameValuePair"

UML Diagram for "org.tquadrat.foundation.lang.NameValuePair"

UML Diagram for "org.tquadrat.foundation.lang.NameValuePair"
  • Field Summary Link icon

    Fields
    Modifier and Type
    Field
    Description
    private final String
    The field for the name record component.
    private final V
    The field for the value record component.
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    NameValuePair(String name, V value)
    Creates a new instance of NameValuePair.
    NameValuePair(Map.Entry<String,? extends V> entry)
    Creates a new instance of NameValuePair from the given Map.Entry instance.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the name record component.
    newValue(V newValue)
    Creates a new instance of NameValuePair that takes the name from this instance and assigns the given new value.
    final String
    Returns a string representation of this record class.
    Returns the value of the value record component.

    Methods inherited from class java.lang.Object Link icon

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details Link icon

    • name Link icon

      private final String name
      The field for the name record component.
    • value Link icon

      private final V value
      The field for the value record component.
  • Constructor Details Link icon

    • NameValuePair Link icon

      public NameValuePair(String name, V value)
      Creates a new instance of NameValuePair.
      Parameters:
      name - The name; may not be null, and it may not be empty.
      value - The value; can be null.
    • NameValuePair Link icon

      public NameValuePair(Map.Entry<String,? extends V> entry)
      Creates a new instance of NameValuePair from the given Map.Entry instance.
      Parameters:
      entry - The entry.
  • Method Details Link icon

    • newValue Link icon

      public final NameValuePair<V> newValue(V newValue)
      Creates a new instance of NameValuePair that takes the name from this instance and assigns the given new value.
      Parameters:
      newValue - The new value; may be null.
      Returns:
      The new instance.
    • toString Link icon

      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 Link icon

      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 Link icon

      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.
    • name Link icon

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • value Link icon

      public V value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component