org.davesag.generica.core
Class Merchant

java.lang.Object
  extended byorg.davesag.generica.core.Merchant
All Implemented Interfaces:
Extensible, Persistable, Serializable

public class Merchant
extends Object
implements Persistable, Serializable, Extensible

A Merchant will be a real world corporate entity and in order to handle payment processing will have a contract with a CreditCardAuthoriser, and a range of ShoppingItems in the shop. You may need to write your own implementation of the CreditCardAuthoriser and if so you should extend AbstractCreditCardAuthoriser.

Since:
Generica 1.0
Version:
CVS Revision $Id: Merchant.java,v 1.13 2004/04/08 13:19:08 davesag Exp $
Author:
Dave Sag http://www.davesag.com
See Also:
Serialized Form
Peristable via Hibernate:
table = "merchants"

Field Summary
protected  List theBanks
          The list names of banks that the Merchant uses.
protected  String theCompanyCode
          The unique company number, eg in australia ABN 12345677, or in Holland BVi 20031117109.
protected  String theEmail
          The email address the Merchant uses.
protected  Long theId
          The merchant's id used as a key by hibernate
protected  Long theMerchantId
          The MerchantId of this Merchant provided by the CreditCardAuthoriser.
protected  Map theMetaData
          a map of application definable meta-data
protected  String theName
          The Merchant's name
 
Constructor Summary
Merchant()
          null constructor required by hibernate.
Merchant(String name, Long id, String code, String email)
          constructor takes a name, id, code and email address.
 
Method Summary
 void addBank(String bankname)
          Add a bank to the Merchant's bank list.
 void addMetaData(String key, String metadata)
          Add a piece of MetaData to this Merchant.
 boolean equals(Object o)
          Tests if the supplied object is equal to this Merchant, ie do they have the same Id?
 List getBanks()
          get the List of bank names this Merchant uses.
 String getCompanyCode()
          Get the country specific, government assigned company code for this Merchant.
 String getEmail()
          Get the Merchant's administrative email address.
 Long getId()
          the merchant id
 Long getMerchantId()
          Get the merchant-id of this Merchant.
 Map getMetaData()
          Get the Map of MetaData about this Merchant.
 Object getMetaData(Object key)
          returns the metadata for the particular key.
 String getName()
          Get the name of this Merchant.
 int hashcode()
          Objects must override the hashcode if they override the equals method.
 void removeBank(String bankname)
          Remove a bank from the Merchant's bank list.
 void removeMetaData(String key)
          Remove a piece of MetaData from this Merchant.
 void setBanks(List banks)
          Set the list of bank names used by this Merchant.
 void setCompanyCode(String code)
          Set the country specifi, government assugned company code of this Merchant.
 void setEmail(String email)
          Set the Merchant's administrative email address.
protected  void setId(Long id)
          Sets the The Merchant's Id number.
 void setMerchantId(Long id)
          Set the Merchant's merchant-id.
 void setMetaData(Map metadata)
          Set this Merchant's MetaData Map.
 void setName(String name)
          Set the Merchant's name.
 void setTemplateId(Long id)
          Sets the The Merchant's ID number directly.
 String toString()
          displays the merchant's name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

theId

protected Long theId
The merchant's id used as a key by hibernate


theName

protected String theName
The Merchant's name


theMerchantId

protected Long theMerchantId
The MerchantId of this Merchant provided by the CreditCardAuthoriser.


theCompanyCode

protected String theCompanyCode
The unique company number, eg in australia ABN 12345677, or in Holland BVi 20031117109. These numbers are issued by the government of the country the company is based in.


theEmail

protected String theEmail
The email address the Merchant uses.


theBanks

protected List theBanks
The list names of banks that the Merchant uses.


theMetaData

protected Map theMetaData
a map of application definable meta-data

Constructor Detail

Merchant

public Merchant()
null constructor required by hibernate.


Merchant

public Merchant(String name,
                Long id,
                String code,
                String email)
constructor takes a name, id, code and email address.

Parameters:
name - The name of the Merchant.
id - The MecrhantId provided to the Merchant by the CreditCardAuthoriser in the real world.
code - The country specific government assignd company code for this Merchant.
email - the contact email address of the Merchant.
Method Detail

getId

public Long getId()
the merchant id

Specified by:
getId in interface Persistable
Returns:
The Merchant's Id number.
Hibernate Unique ID Property:
generator-class = "identity"

setId

protected void setId(Long id)
Sets the The Merchant's Id number.

Parameters:
id - The Id number to set.

setTemplateId

public void setTemplateId(Long id)
Sets the The Merchant's ID number directly. This is only to be used when creating a template object, and is not to be used when creating actual objects that will be persisted.

Specified by:
setTemplateId in interface Persistable
Parameters:
id - The ID number to set.

getName

public String getName()
Get the name of this Merchant.

Returns:
The name of this Merchant.
Hibernate Property:
length = "255" not-null="true" unique="true"

setName

public void setName(String name)
Set the Merchant's name.

Parameters:
name - The User who wrote this this Merchant.

getMerchantId

public Long getMerchantId()
Get the merchant-id of this Merchant.

Returns:
The merchant id of this Merchant.
Hibernate Property:
not-null = "true" unique="true"

setMerchantId

public void setMerchantId(Long id)
Set the Merchant's merchant-id.

Parameters:
id - The merchant id of this Merchant.

getCompanyCode

public String getCompanyCode()
Get the country specific, government assigned company code for this Merchant.

Returns:
The code of this Merchant. May be null.
Hibernate Property:
length = "20"

setCompanyCode

public void setCompanyCode(String code)
Set the country specifi, government assugned company code of this Merchant.

Parameters:
code - The code of this Merchant.

getEmail

public String getEmail()
Get the Merchant's administrative email address.

Returns:
The Merchant's admin email address.
Hibernate Property:
length = "50" not-null="true"

setEmail

public void setEmail(String email)
Set the Merchant's administrative email address.

Parameters:
email - The Merchant's admin email address.

getBanks

public List getBanks()
get the List of bank names this Merchant uses.

Returns:
The bank names used by this Merchant.
Hibernate List:
cascade = "all" lazy="true"

setBanks

public void setBanks(List banks)
Set the list of bank names used by this Merchant.

Parameters:
banks - The List of bank names used by this Merchant.

addBank

public void addBank(String bankname)
Add a bank to the Merchant's bank list.

Parameters:
bankname - The name of the bank to add.

removeBank

public void removeBank(String bankname)
Remove a bank from the Merchant's bank list.

Parameters:
bankname - The name of the bank to remove.

getMetaData

public Map getMetaData()
Get the Map of MetaData about this Merchant.

Specified by:
getMetaData in interface Extensible
Returns:
The Map of MetaData about this Merchant.
Hibernate Map:
table = "merchant_metadata" cascade="all"

getMetaData

public Object getMetaData(Object key)
returns the metadata for the particular key.

Specified by:
getMetaData in interface Extensible
Parameters:
key - The key to the bit of meta data you want.
Returns:
The Value corresponding to the key.

setMetaData

public void setMetaData(Map metadata)
Set this Merchant's MetaData Map.

Specified by:
setMetaData in interface Extensible
Parameters:
metadata - The Map of meta data for this Merchant.

addMetaData

public void addMetaData(String key,
                        String metadata)
Add a piece of MetaData to this Merchant.

Specified by:
addMetaData in interface Extensible
Parameters:
key - The key under which to file the meta data.
metadata - The meta data to add.

removeMetaData

public void removeMetaData(String key)
Remove a piece of MetaData from this Merchant.

Specified by:
removeMetaData in interface Extensible
Parameters:
key - The MetaData key to remove.

toString

public String toString()
displays the merchant's name.

Returns:
the Merchant's name. useful for debugging.

equals

public boolean equals(Object o)
Tests if the supplied object is equal to this Merchant, ie do they have the same Id?

Parameters:
o - The object to test against this Merchant. Must also be a Merchant to make sense.
Returns:
true if the two users have the same id.

hashcode

public int hashcode()
Objects must override the hashcode if they override the equals method.

Returns:
a valid hashcode for this Merchant.


Dave Sag Generica API version 0.5.9 - (prerelease) Copyright 2003 - 2004 Dave Sag.