Object
Customer
Entity class representing a Customer as a person who creates
and holds (owns) orders in the system.
- Version:
"C12-1.0.0-SNAPSHOT"
- Author:
"sgraupner"
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddContact
(String contact) Add new Customer contact, only valid contacts (not null, not empty "", at least 6 characters and no duplicate contacts) are added.int
Return the number of contacts.void
Delete all contacts.void
deleteContact
(int i) Delete the i-th contact withi >= 0
andi < contactsCount()
, otherwise method has no effect.Contacts getter as immutableIterable<String>
.FirstName getter, return value of firstName attribute, never null.long
getId()
Id getter, returns-1
, if id is still unassigned.LastName getter, return value of lastName attribute, never null.setId
(long id) Id setter, id can only be set once with a valid id value:id >= 0
, id is immutable after first assignment, return chainable self-reference.Setter that splits a single-String name ("Eric Meyer") into first- and lastName parts and assigns parts to the corresponding attributes (see methodsplitName(java.lang.String)
for details).Setter for first- ("Eric") and lastName ("Meyer") attributes, return chainable self-reference.
-
Constructor Details
-
Customer
public Customer()Default constructor. -
Customer
Constructor with single-String name argument, for example "Eric Meyer" (see methodsplitName(java.lang.String)
for details).- Parameters:
name
- single-String Customer name- Throws:
IllegalArgumentException
- if name argument is null or empty
-
-
Method Details
-
getId
public long getId()Id getter, returns-1
, if id is still unassigned.- Returns:
- customer id, returns
-1
, if id is still unassigned.
-
setId
Id setter, id can only be set once with a valid id value:id >= 0
, id is immutable after first assignment, return chainable self-reference.- Parameters:
id
- value to assign, if id attribute is still unassignedid < 0
and the id argument is valid- Returns:
- chainable self-reference
- Throws:
IllegalArgumentException
- if called with invalid (id < 0
) argument
-
getLastName
LastName getter, return value of lastName attribute, never null.- Returns:
- value of lastName attribute, never null
-
getFirstName
FirstName getter, return value of firstName attribute, never null.- Returns:
- value of firstName attribute, never null
-
setName
Setter for first- ("Eric") and lastName ("Meyer") attributes, return chainable self-reference.- Parameters:
first
- value assigned to firstName attribute, must not be null or empty ""last
- value assigned to lastName attribute, must not be null, empty "" first name is allowed- Returns:
- chainable self-reference
- Throws:
IllegalArgumentException
- if first or last name argument is null or last name is empty
-
setName
Setter that splits a single-String name ("Eric Meyer") into first- and lastName parts and assigns parts to the corresponding attributes (see methodsplitName(java.lang.String)
for details).- Parameters:
name
- single-String name to split into first- and lastName parts- Returns:
- chainable self-reference
- Throws:
IllegalArgumentException
- if name argument is null or empty
-
contactsCount
public int contactsCount()Return the number of contacts.- Returns:
- number of contacts
-
getContacts
Contacts getter as immutableIterable<String>
.- Returns:
- contacts as immutable
Iterable<String>
-
addContact
Add new Customer contact, only valid contacts (not null, not empty "", at least 6 characters and no duplicate contacts) are added.- Parameters:
contact
- contact to add, only valid contacts are added- Returns:
- chainable self-reference
- Throws:
IllegalArgumentException
- if contact argument is null or empty
-
deleteContact
public void deleteContact(int i) Delete the i-th contact withi >= 0
andi < contactsCount()
, otherwise method has no effect.- Parameters:
i
- index of contact to delete
-
deleteAllContacts
public void deleteAllContacts()Delete all contacts.
-