Class Supplier

All Implemented Interfaces:
Serializable, Comparable<Supplier>

public class Supplier extends CustomerEntity implements Serializable, Comparable<Supplier>
The Supplier Entity for the Customer application.

This class represents the following DB Table:

 CREATE TABLE SUPPLIER (
      ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
      COMPANY_NAME VARCHAR(40) NOT NULL,
      CONTACT_NAME VARCHAR(50),
      CITY VARCHAR(40),
      COUNTRY VARCHAR(40),
      PHONE VARCHAR(20),
      FAX VARCHAR(30),
      CONSTRAINT PK_SUPPLIER PRIMARY KEY (ID)
   );
 
Version:
1.0
Author:
Jonathan Earl
See Also:
  • Constructor Details

    • Supplier

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

      The initial values are:

      • id: 1
      • first name: ABC Inc.
      • last name: John Smith
      • city: New York City
      • country: United States of America
      • phone: null
      • fax: null
    • Supplier

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

      The initial values are:

      • id: 1
      • first name: ABC Inc.
      • last name: John Smith
      • city: New York City
      • country: United States of America
      • phone: null
      • fax: null
      Parameters:
      sanitizer - the XssSanitizer used by this instance
  • Method Details

    • getCompanyName

      public String getCompanyName()
      Returns the company name value for the Supplier.
      Returns:
      the company name value for the Supplier
    • compareTo

      public int compareTo(Supplier other)
      This will enable sorting of Suppliers by company name.

      Specified by:
      compareTo in interface Comparable<Supplier>
      Parameters:
      other - the Supplier object to compare with
      Returns:
      the sort value of negative/zero/positive
    • setCompanyName

      public void setCompanyName(String companyName)
      Sets the company name value for the Supplier.

      The business rules are:

      • the company name must not be null
      • the company name must not be empty
      • the company name must max length of 40 chars
      • XSS strings within the company name will be removed
      Parameters:
      companyName - the value to set into the customer company name field
      Throws:
      IllegalArgumentException - if the company name is invalid
    • getContactName

      public String getContactName()
      Returns the contactName value for the Supplier.
      Returns:
      the contactName value for the Supplier
    • setContactName

      public void setContactName(String contactName)
      Sets the contactName value for the Supplier.

      The business rules are:

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

      public Location getLocation()
      Return the Location for the Supplier.

      Returns:
      the myLocation
    • setLocation

      public void setLocation(Location location)
      Sets the location value for the Supplier.

      The business rules are:

      • the location may be null
      Parameters:
      location - the value to set into the supplier location field
      Throws:
      IllegalArgumentException - if the location is invalid
    • getPhone

      public Phone getPhone()
      Returns the phone value for the Supplier.
      Returns:
      the phone value for the supplier
    • setPhone

      public void setPhone(Phone phone)
      Sets the phone value for the Supplier.

      The business rules are:

      • the phone may be null
      Parameters:
      phone - the value to set into the supplier phone field
      Throws:
      IllegalArgumentException - if the phone is invalid
    • getFax

      public Phone getFax()
      Returns the fax value for the Supplier.
      Returns:
      the fax value for the supplier
    • setFax

      public void setFax(Phone fax)
      Sets the fax value for the Supplier.

      The business rules are:

      • the fax may be null
      Parameters:
      fax - the value to set into the supplier fax field
      Throws:
      IllegalArgumentException - if the phone is invalid
    • hashCode

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

      This method uses:

      • id
      • company name
      • city
      • country
      • phone
      Overrides:
      hashCode in class CustomerEntity
      Returns:
      the hashCode value for this Customer object
      See Also:
    • equals

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

      This method uses:

      • id
      • company name
      • city
      • country
      • phone
      Overrides:
      equals in class CustomerEntity
      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 Supplier class. this method will return:
      Supplier [Id=xxx, CompanyName=xxx, City=xxx, myCountry=xxx, myPhone=xxx]
      Overrides:
      toString in class CustomerEntity