Package com.storedobject.core
Interface HasContacts
- All Known Implementing Classes:
AccountEntity
,BusinessEntity
,Entity
,EntityRole
,Organization
,Person
,PersonalEntity
,PersonRole
public interface HasContacts
Definition of "contact" interface. A
StoredObject
that implements this interface keeps contact
information (See Contact
) as links under it. Different StoredObject
classes may keep different
sets of contact information types (See ContactType
) and that is determined by the value returned by the
method getContactGroupingCode()
. The default value returned by the getContactGroupingCode()
method is 0 and that is what the Person
class uses. So, if you don't implement different code in
your class, it will share the same set of contact types with Person
class.
Entity
and EntityRole
classes also return 0 from the method
getContactGroupingCode()
but since EntityRole
is always extended by your custom class,
you can override that to return any specific value.
- Author:
- Syam
-
Method Summary
Modifier and TypeMethodDescriptiondefault Address
Get the address.default Address
getAddress
(String addressTypeName) Get the address.default String
getContact
(ContactType contactType) Get the contact value (human-friendly) for a specific type of contact.default String
getContact
(String contactType) Get the contact value (human-friendly) for a specific type of contact.default int
Get the contact grouping code of this class.default Contact
getContactObject
(ContactType contactType) Get the contact value for a specific type of contact.default Contact
getContactObject
(Id contactTypeId) Get the contact value for a specific type of contact.default Contact
getContactObject
(String contactType) Get the contact value for a specific type of contact.default Id
Get theId
of the object that owns the contact.default String
getContactRaw
(ContactType contactType) Get the raw contact value (encoded in some cases) for a specific type of contact.default String
getContactRaw
(String contactType) Get the raw contact value (encoded in some cases) for a specific type of contact.default String
getEmail()
Get the email address.default String
Get the address.getId()
Get the Id.default long
Get the mobile number.default String
getName()
Name of the contact.default long
getPhone()
Get the phone number.default long
Get the address.default String
Get the telegram contact.default ObjectIterator
<Contact> List all contact instances of this class instance.default ObjectIterator
<ContactType> List all the supported contact types.static long
phoneToNumber
(String phone) default void
setContact
(TransactionManager tm, String contactType, String contactValue) Set a contact value for this instance.default void
setContact
(Transaction transaction, String contactType, String contactValue) Deprecated.
-
Method Details
-
getId
-
getName
Name of the contact. The default implementation returnsnull
.- Returns:
- Name of the contact.
-
listContactTypes
List all the supported contact types. This method should return a constant list.- Returns:
- Stream of contact types supported by this class.
-
listContacts
List all contact instances of this class instance.- Returns:
- Stream of contact instances.
-
getContact
-
getContact
Get the contact value (human-friendly) for a specific type of contact.- Parameters:
contactType
- Type of contact.- Returns:
- Contact value or null if it doesn't exist.
-
getContactRaw
Get the raw contact value (encoded in some cases) for a specific type of contact.- Parameters:
contactType
- Type of contact ("email", "address", "mobile" etc. defined in the contact type).- Returns:
- Raw value of the contact or null if it doesn't exist.
-
getContactRaw
Get the raw contact value (encoded in some cases) for a specific type of contact.- Parameters:
contactType
- Type of contact.- Returns:
- Raw value of the contact or null if it doesn't exist.
-
getContactObject
-
getContactObject
Get the contact value for a specific type of contact.- Parameters:
contactType
- Type of contact.- Returns:
- Contact or null if it doesn't exist.
-
getContactObject
-
getContactOwnerId
Get theId
of the object that owns the contact. (It is possible that some other related object may be owing the contact information).- Returns:
- By default, the same instance of the class owns the contact and thus, it returns
StoredObject.getId()
.
-
getContactGroupingCode
default int getContactGroupingCode()Get the contact grouping code of this class. This method should return a constant value.- Returns:
- Default value is 0.
-
setContact
@Deprecated default void setContact(Transaction transaction, String contactType, String contactValue) throws Exception Deprecated.User thesetContact(TransactionManager, String, String)
instead.Set a contact value for this instance.- Parameters:
transaction
- Transaction.contactType
- Type of contact.contactValue
- Value of the contact (must be raw value). Ifnull
is passed, existing value if any, will be deleted.- Throws:
Exception
- If contact information is invalid or any error occurs while saving to the database.
-
setContact
default void setContact(TransactionManager tm, String contactType, String contactValue) throws Exception Set a contact value for this instance.- Parameters:
tm
- Transaction manager.contactType
- Type of contact.contactValue
- Value of the contact (must be raw value). Ifnull
is passed, existing value if any, will be deleted.- Throws:
Exception
- If contact information is invalid or any error occurs while saving to the database.
-
getAddress
Get the address. (It will look for an address with address type name "Address").- Returns:
- Address instance if available, otherwise
null
.
-
getAddress
-
getEmail
Get the email address. (It will look for an email address with type name "Email").- Returns:
- Email address if available, otherwise
null
.
-
getEmail
-
getPhone
default long getPhone()Get the phone number. (It will look for a phone number with type name "Phone").- Returns:
- Phone number if available, otherwise
null
.
-
getPhone
Get the address.- Parameters:
typeName
- Name of the email (as defined in the respective grouping).- Returns:
- Phone number if available, otherwise
null
.
-
phoneToNumber
-
getMobile
default long getMobile()Get the mobile number. (It will look for a phone number with type name "Mobile").- Returns:
- Mobile number if available, otherwise
null
.
-
getTelegram
Get the telegram contact.- Returns:
- Telegram contact if available, otherwise
null
.
-
setContact(TransactionManager, String, String)
instead.