Record Class Address

java.lang.Object
java.lang.Record
net.tangly.core.Address
Record Components:
street - street and street number of the address
extended - extended address line of the address
poBox - optional postal box code of the address
postcode - zip code of the address as custom in the country
locality - mandatory locality of the address
region - region of the address as custom in the country
country - mandatory country of the address as ISO 2 characters code

public record Address(String street, String extended, String poBox, String postcode, String locality, String region, String country) extends Record
Address immutability is enforced through a record construct. The street represents the international concept of house identifier often means street name and street number. It can also be the street name and house name such as in Ireland or Great Britain.
  • Constructor Details

    • Address

      public Address(String street, String extended, String poBox, String postcode, String locality, String region, String country)
      Creates an instance of a Address record class.
      Parameters:
      street - the value for the street record component
      extended - the value for the extended record component
      poBox - the value for the poBox record component
      postcode - the value for the postcode record component
      locality - the value for the locality record component
      region - the value for the region record component
      country - the value for the country record component
  • Method Details

    • builder

      public static Address.Builder builder()
      Returns a builder instance for an address object. The builder can be used to create multiple address objects
      Returns:
      builder instance
    • text

      public String text()
      Returns a comma-separated representation of an address. Null values are shown as empty strings. The Object.toString() method is not used because the implementation is defined in the API implementation of record construct. The generated string can be feed to the of(String) to create an address object.
      Returns:
      comma separated representation
      See Also:
    • of

      public static Address of(@NotNull @NotNull String text)
      Builds an address object from a comma separated string representation.
      Parameters:
      text - comma separated representation of the address instance
      Returns:
      new address object
      See Also:
    • 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.
    • street

      public String street()
      Returns the value of the street record component.
      Returns:
      the value of the street record component
    • extended

      public String extended()
      Returns the value of the extended record component.
      Returns:
      the value of the extended record component
    • poBox

      public String poBox()
      Returns the value of the poBox record component.
      Returns:
      the value of the poBox record component
    • postcode

      public String postcode()
      Returns the value of the postcode record component.
      Returns:
      the value of the postcode record component
    • locality

      public String locality()
      Returns the value of the locality record component.
      Returns:
      the value of the locality record component
    • region

      public String region()
      Returns the value of the region record component.
      Returns:
      the value of the region record component
    • country

      public String country()
      Returns the value of the country record component.
      Returns:
      the value of the country record component