Package datamodel

Class Customer

Object
Customer

public class Customer extends Object
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
    Constructor
    Description
    Default constructor.
    Constructor with single-String name argument, for example "Eric Meyer" (see method splitName(java.lang.String) for details).
  • Method Summary

    Modifier and Type
    Method
    Description
    addContact(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
    Delete the i-th contact with i >= 0 and i < contactsCount(), otherwise method has no effect.
    Contacts getter as immutable Iterable<String>.
    FirstName getter, return value of firstName attribute, never null.
    long
    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 method splitName(java.lang.String) for details).
    setName(String first, String last)
    Setter for first- ("Eric") and lastName ("Meyer") attributes, return chainable self-reference.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Customer

      public Customer()
      Default constructor.
    • Customer

      public Customer(String name)
      Constructor with single-String name argument, for example "Eric Meyer" (see method splitName(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

      public Customer 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.
      Parameters:
      id - value to assign, if id attribute is still unassigned id < 0 and the id argument is valid
      Returns:
      chainable self-reference
      Throws:
      IllegalArgumentException - if called with invalid (id < 0) argument
    • getLastName

      public String getLastName()
      LastName getter, return value of lastName attribute, never null.
      Returns:
      value of lastName attribute, never null
    • getFirstName

      public String getFirstName()
      FirstName getter, return value of firstName attribute, never null.
      Returns:
      value of firstName attribute, never null
    • setName

      public Customer setName(String first, String last)
      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

      public Customer setName(String name)
      Setter that splits a single-String name ("Eric Meyer") into first- and lastName parts and assigns parts to the corresponding attributes (see method splitName(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

      public Iterable<String> getContacts()
      Contacts getter as immutable Iterable<String>.
      Returns:
      contacts as immutable Iterable<String>
    • addContact

      public Customer addContact(String contact)
      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 with i >= 0 and i < contactsCount(), otherwise method has no effect.
      Parameters:
      i - index of contact to delete
    • deleteAllContacts

      public void deleteAllContacts()
      Delete all contacts.