Package org.example.customer
Class Supplier
java.lang.Object
org.example.customer.utility.CustomerEntity
org.example.customer.Supplier
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintThis will enable sorting of Suppliers by company name.booleanThe equals() method of the Supplier class.Returns the company name value for the Supplier.Returns the contactName value for the Supplier.getFax()Returns the fax value for the Supplier.Return the Location for the Supplier.getPhone()Returns the phone value for the Supplier.inthashCode()The hashCode() method of the Supplier class.voidsetCompanyName(String companyName) Sets the company name value for the Supplier.voidsetContactName(String contactName) Sets the contactName value for the Supplier.voidSets the fax value for the Supplier.voidsetLocation(Location location) Sets the location value for the Supplier.voidSets the phone value for the Supplier.toString()The toString method for the Supplier class.Methods inherited from class org.example.customer.utility.CustomerEntity
getId, setId
-
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
Returns the company name value for the Supplier.- Returns:
- the company name value for the Supplier
-
compareTo
This will enable sorting of Suppliers by company name.
- Specified by:
compareToin interfaceComparable<Supplier>- Parameters:
other- the Supplier object to compare with- Returns:
- the sort value of negative/zero/positive
-
setCompanyName
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
Returns the contactName value for the Supplier.- Returns:
- the contactName value for the Supplier
-
setContactName
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
Return the Location for the Supplier.
- Returns:
- the myLocation
-
setLocation
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
Returns the phone value for the Supplier.- Returns:
- the phone value for the supplier
-
setPhone
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
Returns the fax value for the Supplier.- Returns:
- the fax value for the supplier
-
setFax
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:
hashCodein classCustomerEntity- Returns:
- the hashCode value for this Customer object
- See Also:
-
equals
The equals() method of the Supplier class.This method uses:
- id
- company name
- city
- country
- phone
- Overrides:
equalsin classCustomerEntity- Parameters:
obj- the incoming object to compare against- Returns:
- true if the fields being compared are equal
- See Also:
-
toString
The toString method for the Supplier class. this method will return:
Supplier [Id=xxx, CompanyName=xxx, City=xxx, myCountry=xxx, myPhone=xxx]- Overrides:
toStringin classCustomerEntity
-