Class Phone

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

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

This class represents the common Phone/Fax field in the Customer Database
Version:
1.0
Author:
Jonathan Earl
See Also:
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    boolean
    The equals() method of the Phone class.
    Returns the number value for the Phone.
    int
    The hashCode() method of the Phone class.
    void
    setNumber(String number)
    Sets the number value for the Phone.
    The toString method for the Phone class.

    Methods inherited from class java.lang.Object

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

    • Phone

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

      The initial values are:

      • number: null
    • Phone

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

      The initial values are:

      • number: null
      Parameters:
      sanitizer - the XssSanitizer used by this instance
  • Method Details

    • getNumber

      public String getNumber()
      Returns the number value for the Phone.
      Returns:
      the number value for the Phone
    • setNumber

      public void setNumber(String number)
      Sets the number value for the Phone.

      The business rules are:

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

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

      This method uses:

      • number
      Overrides:
      hashCode in class Object
      Returns:
      the hashCode value for this Phone object
      See Also:
    • equals

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

      This method uses:

      • number
      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 Phone class. this method will return:
      Phone [Number=XXX]
      Overrides:
      toString in class Object