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 AddressGet the address.default AddressgetAddress(String addressTypeName) Get the address.default StringgetContact(ContactType contactType) Get the contact value (human-friendly) for a specific type of contact.default StringgetContact(String contactType) Get the contact value (human-friendly) for a specific type of contact.default intGet the contact grouping code of this class.default ContactgetContactObject(ContactType contactType) Get the contact value for a specific type of contact.default ContactgetContactObject(Id contactTypeId) Get the contact value for a specific type of contact.default ContactgetContactObject(String contactType) Get the contact value for a specific type of contact.default IdGet theIdof the object that owns the contact.default StringgetContactRaw(ContactType contactType) Get the raw contact value (encoded in some cases) for a specific type of contact.default StringgetContactRaw(String contactType) Get the raw contact value (encoded in some cases) for a specific type of contact.default StringgetEmail()Get the email address.default StringGet the address.getId()Get the Id.default longGet the mobile number.default StringgetName()Name of the contact.default longgetPhone()Get the phone number.default longGet the address.default StringGet the telegram contact.default ObjectIterator<Contact> List all contact instances of this class instance.default ObjectIterator<ContactType> List all the supported contact types.static longphoneToNumber(String phone) default voidsetContact(TransactionManager tm, String contactType, String contactValue) Set a contact value for this instance.default voidsetContact(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 theIdof 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). Ifnullis 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). Ifnullis 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.