java.lang.Object
de.powerstat.validation.values.Address
All Implemented Interfaces:
IValueObject, Comparable<Address>
Direct Known Subclasses:
AddressWithWGS84Position

public class Address extends Object implements Comparable<Address>, IValueObject
Address. DSGVO relevant. TODO COUNTRYNAME - English country names TODO vcard, hcard, ldap, vcard+xml -> Data mappings/converter TODO Get/cache GPS posiion for address
  • Field Details

  • Constructor Details

    • Address

      protected Address(Country country, PostalCode postalCode, City city, Province province, District district, Street street, BuildingNr buildingNr, BuildingName buildingName, SubBuilding subBuilding, PoBoxNumber poBoxNumber, Department department, Neighbourhood neighbourhood, Block block, BFPONumber bFPONumber, Lines lines)
      Constructor.
      Parameters:
      country - Country
      postalCode - Postal code
      city - City
      province - Province
      district - District
      street - Street
      buildingNr - Bulding number
      buildingName - Building name
      subBuilding - Sub building
      poBoxNumber - Post office box number
      department - Department
      neighbourhood - Neighbourhood
      block - Block
      bFPONumber - British Forces Post Office Number
      lines - Lines 1-5
      Throws:
      NullPointerException - When country or some other required field is null.
  • Method Details

    • of

      public static Address of(Country country, PostalCode postalCode, City city, Province province, District district, Street street, BuildingNr buildingNr, BuildingName buildingName, SubBuilding subBuilding, PoBoxNumber poBoxNumber, Department department, Neighbourhood neighbourhood, Block block, BFPONumber bFPONumber, Lines lines)
      Address factory.
      Parameters:
      country - Country
      postalCode - Postal code
      city - City
      province - Province
      district - District
      street - Street
      buildingNr - Bulding number
      buildingName - Building name
      subBuilding - Sub building
      poBoxNumber - Post office box number
      department - Department
      neighbourhood - Neighbourhood
      block - Block
      bFPONumber - British Forces Post Office Number
      lines - Lines 1-5
      Returns:
      Address object
    • of

      public static Address of(String value)
      Address factory.
      Parameters:
      value - country,postalcode,city,province,district,street,buildingnr,buildingname,subbuilding,poboxnumber,department,neighbourhood,block,bfponumber,lines
      Returns:
      Address object
    • stringValue

      public String stringValue()
      Returns the value of this Address as a string.
      Specified by:
      stringValue in interface IValueObject
      Returns:
      The text value represented by this object after conversion to type string.
    • hashCode

      public int hashCode()
      Calculate hash code.
      Overrides:
      hashCode in class Object
      Returns:
      Hash
      See Also:
    • equalField

      private static <T> boolean equalField(T obj1, T obj2)
      Equal fields.
      Type Parameters:
      T - Field type
      Parameters:
      obj1 - Field 1 (this)
      obj2 - Field 2 (other)
      Returns:
      true: equal; false: not equal
    • equals

      public boolean equals(Object obj)
      Is equal with another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - Object
      Returns:
      true when equal, false otherwise
      See Also:
    • toString

      public String toString()
      Returns the string representation of this Address. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "Address[country=DE, postalCode=28000, city=Bremen, province=, district=, street=Hemelinger Heerstr., buildingNr=4711, buildingName=Rathaus, subBuiding=Floor 13, Apart. 0815, poBoxNumber=4711, department=Research, neighbourhood=, block=A, bFPONumber=2, lines=]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this Address
      See Also:
    • compareField

      private static <T extends Comparable<T>> int compareField(T obj1, T obj2)
      Compare fields.
      Type Parameters:
      T - Field type
      Parameters:
      obj1 - Field 1 (this)
      obj2 - Field 2 (other)
      Returns:
      0: equal; 1 field 1 greater than field 2; -1 field 1 smaller than field 2
    • compareTo

      public int compareTo(Address obj)
      Compare with another object.
      Specified by:
      compareTo in interface Comparable<Address>
      Parameters:
      obj - Object to compare with
      Returns:
      0: equal; 1: greater; -1: smaller
      See Also:
    • processBlocks

      private String processBlocks(String formatStr, String... vars)
      Process format blocks.
      Parameters:
      formatStr - Format string
      vars - Format variables (16) 01: COUNTRYNAME 02: Company 03: POSTALCODE 04: City 05: Province 06: District 07: Street 08: BuildingNumber 09: BuildingName 10: SubBuilding 11: PoBoxNumber 12: Department 13: Neighbourhood 14: Block 15: BFPONUMBER 16: Line1-5
      Returns:
      Format with removed blocks for non existing parameters
    • getAddressFormat

      private String getAddressFormat(String... vars)
      Get address format depending on country.
      Parameters:
      vars - 16 Strings
      Returns:
      Java formatter string 01: COUNTRYNAME 02: Company 03: POSTALCODE 04: City 05: Province 06: District 07: Street 08: BuildingNumber 09: BuildingName 10: SubBuilding 11: PoBoxNumber 12: Department 13: Neighbourhood 14: Block 15: BFPONUMBER 16: Line1-5
    • getFormattedAddress

      public String getFormattedAddress(String recipientName)
      Get formatted address string.
      Parameters:
      recipientName - Company or person name
      Returns:
      Formatted address string
      Throws:
      NullPointerException - If recipientName is null
    • getCountry

      public Country getCountry()
      Get country.
      Returns:
      The country
    • getPostalCode

      public PostalCode getPostalCode()
      Get postalCode.
      Returns:
      The postalCode
    • getCity

      public City getCity()
      Get city.
      Returns:
      The city
    • getProvince

      public Province getProvince()
      Get province.
      Returns:
      The province
    • getDistrict

      public District getDistrict()
      Get district.
      Returns:
      The district
    • getStreet

      public Street getStreet()
      Get street.
      Returns:
      The street
    • getBuildingNr

      public BuildingNr getBuildingNr()
      Get buildingNr.
      Returns:
      The buildingNr
    • getBuildingName

      public BuildingName getBuildingName()
      Get buildingName.
      Returns:
      The buildingName
    • getSubBuilding

      public SubBuilding getSubBuilding()
      Get subBuilding.
      Returns:
      The subBuilding
    • getPoBoxNumber

      public PoBoxNumber getPoBoxNumber()
      Get poBoxNumber.
      Returns:
      The poBoxNumber
    • getDepartment

      public Department getDepartment()
      Get department.
      Returns:
      The department
    • getNeighbourhood

      public Neighbourhood getNeighbourhood()
      Get neighbourhood.
      Returns:
      The neighbourhood
    • getBlock

      public Block getBlock()
      Get block.
      Returns:
      The block
    • getBFPONumber

      public BFPONumber getBFPONumber()
      Get bFPONumber.
      Returns:
      The bFPONumber
    • getLines

      public Lines getLines()
      Get lines.
      Returns:
      The lines