Package org.example.customer.utility
Class Location
java.lang.Object
org.example.customer.utility.Location
- All Implemented Interfaces:
Serializable
The Customer Location for the Customer application.
This class represents the common City and Country fields in the Customer Database
This class represents the common City and Country fields in the Customer Database
- Version:
- 1.0
- Author:
- Jonathan Earl
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanThe equals() method of the Location class.getCity()Returns the city value for the Location.Returns the country value for the Location.inthashCode()The hashCode() method of the Location class.voidSets the city value for the Location.voidsetCountry(String country) Sets the country value for the Location.toString()The toString method for the Location class.
-
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
Returns the city value for the Location.- Returns:
- the city value for the location
-
setCity
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
Returns the country value for the Location.- Returns:
- the country value for the location
-
setCountry
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
-
equals
The equals() method of the Location class.This method uses:
- city
- country
-
toString
The toString method for the Location class. this method will return:
Location [City=xxx Country=XXX]
-