Record Class Address
java.lang.Object
java.lang.Record
net.tangly.core.Address
- Record Components:
street- street and street number of the addressextended- extended address line of the addresspoBox- optional postal box code of the addresspostcode- zip code of the address as custom in the countrylocality- mandatory locality of the addressregion- region of the address as custom in the countrycountry- 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefines the builder for the address class with a fluent interface. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Address.Builderbuilder()Returns a builder instance for an address object.country()Returns the value of thecountryrecord component.final booleanIndicates whether some other object is "equal to" this one.extended()Returns the value of theextendedrecord component.final inthashCode()Returns a hash code value for this object.locality()Returns the value of thelocalityrecord component.static AddressBuilds an address object from a comma separated string representation.poBox()Returns the value of thepoBoxrecord component.postcode()Returns the value of thepostcoderecord component.region()Returns the value of theregionrecord component.street()Returns the value of thestreetrecord component.text()Returns a comma-separated representation of an address.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Address
public Address(String street, String extended, String poBox, String postcode, String locality, String region, String country) Creates an instance of aAddressrecord class.- Parameters:
street- the value for thestreetrecord componentextended- the value for theextendedrecord componentpoBox- the value for thepoBoxrecord componentpostcode- the value for thepostcoderecord componentlocality- the value for thelocalityrecord componentregion- the value for theregionrecord componentcountry- the value for thecountryrecord component
-
-
Method Details
-
builder
Returns a builder instance for an address object. The builder can be used to create multiple address objects- Returns:
- builder instance
-
text
Returns a comma-separated representation of an address. Null values are shown as empty strings. TheObject.toString()method is not used because the implementation is defined in the API implementation of record construct. The generated string can be feed to theof(String)to create an address object.- Returns:
- comma separated representation
- See Also:
-
of
-
toString
-
hashCode
-
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). -
street
-
extended
-
poBox
-
postcode
-
locality
-
region
-
country
-