Class Location

java.lang.Object
org.example.customer.utility.Location
All Implemented Interfaces:
Serializable

public class Location extends Object implements Serializable
The Customer Location for the Customer application.

This class represents the common City and Country fields in the Customer Database
Version:
1.0
Author:
Jonathan Earl
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    The default constructor for the Location class.
    Location(org.example.websecurity.XssSanitizer sanitizer)
    The overloaded constructor for the Location class that takes an XssSanitizer as input.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    The equals() method of the Location class.
    Returns the city value for the Location.
    Returns the country value for the Location.
    int
    The hashCode() method of the Location class.
    void
    Sets the city value for the Location.
    void
    setCountry(String country)
    Sets the country value for the Location.
    The toString method for the Location class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Location

      public Location()
      The default constructor for the Location class.

      The initial values are:

      • city: New York City
      • country: United States of America
    • Location

      public Location(org.example.websecurity.XssSanitizer sanitizer)
      The overloaded constructor for the Location class that takes an XssSanitizer as input.

      The initial values are:

      • city: New York City
      • country: United States of America
      Parameters:
      sanitizer - the XssSanitizer used by this instance
  • Method Details

    • getCity

      public String getCity()
      Returns the city value for the Location.
      Returns:
      the city value for the location
    • setCity

      public void setCity(String city)
      Sets the city value for the Location.

      The business rules are:

      • the city may be null
      • the city must not be empty
      • the city must min length of 2 chars
      • the city must max length of 40 chars
      • XSS strings within the city will be removed
      Parameters:
      city - the value to set into the location city field
      Throws:
      IllegalArgumentException - if the city is invalid
    • getCountry

      public String getCountry()
      Returns the country value for the Location.
      Returns:
      the country value for the location
    • setCountry

      public void setCountry(String country)
      Sets the country value for the Location.

      The business rules are:

      • the country may be null
      • the country must not be empty
      • the country must min length of 2 chars
      • the country must max length of 40 chars
      • XSS strings within the country will be removed
      Parameters:
      country - the value to set into the location country field
      Throws:
      IllegalArgumentException - if the country is invalid
    • hashCode

      public int hashCode()
      The hashCode() method of the Location class.

      This method uses:

      • city
      • country
      Overrides:
      hashCode in class Object
      Returns:
      the hashCode value for this Location object
      See Also:
    • equals

      public boolean equals(Object obj)
      The equals() method of the Location class.

      This method uses:

      • city
      • country
      Overrides:
      equals in class Object
      Parameters:
      obj - the incoming object to compare against
      Returns:
      true if the fields being compared are equal
      See Also:
    • toString

      public String toString()
      The toString method for the Location class. this method will return:
      Location [City=xxx Country=XXX]
      Overrides:
      toString in class Object