Package org.gbif.api.util
Class ContactAdapter
- java.lang.Object
-
- org.gbif.api.util.ContactAdapter
-
public class ContactAdapter extends Object
- Author:
- cgendreau
-
-
Constructor Summary
Constructors Constructor Description ContactAdapter(List<Contact> contacts)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
formatContactName(Contact contact)
Format the name of the contact as "FirstName LastName".Contact
getAdministrativeContact()
Get the AdministrativeContactContact
.List<Contact>
getAllType(ContactType type)
Get allContact
for the provided type.List<Contact>
getAssociatedParties()
Get the list of AssociatedParties.List<Contact>
getContacts()
Get the list ofContact
of type ContactType.ADMINISTRATIVE_POINT_OF_CONTACT.List<Contact>
getCreators()
Get the list ofContact
of type ContactType.ORIGINATOR.List<Contact>
getFilteredContacts(ContactType... types)
Filter contacts based on the provided contact types.Contact
getFirstPreferredType(ContactType type)
Get the first primaryContact
for the provided type.List<Contact>
getMetadataProviders()
Get the list ofContact
of type ContactType.METADATA_AUTHOR.Contact
getResourceCreator()
Get the ResourceCreatorContact
.
-
-
-
Constructor Detail
-
ContactAdapter
public ContactAdapter(List<Contact> contacts)
-
-
Method Detail
-
getAssociatedParties
public List<Contact> getAssociatedParties()
Get the list of AssociatedParties. This is defined as all non-primaryContact
, excluding contacts with types the following types considered primary types: Originator, MetadataAuthor and AdministrativePointOfContact.- Returns:
- list of AssociatedParties or empty list if none found
-
getResourceCreator
public Contact getResourceCreator()
Get the ResourceCreatorContact
. This is defined as the first primaryContact
of type ContactType.ORIGINATOR.- Returns:
- first preferred ResourceCreator found or null if none were found
-
formatContactName
public static String formatContactName(Contact contact)
Format the name of the contact as "FirstName LastName".- Parameters:
contact
- contact- Returns:
- formatted name or "" if the contact is null or empty
-
getAdministrativeContact
public Contact getAdministrativeContact()
Get the AdministrativeContactContact
. This is defined as the first primaryContact
of type ContactType.ADMINISTRATIVE_POINT_OF_CONTACT.- Returns:
- first preferred AdministrativeContact found or null if none were found
-
getFilteredContacts
public List<Contact> getFilteredContacts(ContactType... types)
Filter contacts based on the provided contact types. The order in which the ContactType are provided will be respected in the response except missing ContactType will be ommited. Filtering is done by thegetFirstPreferredType(org.gbif.api.vocabulary.ContactType)
method.- Parameters:
types
- contact types- Returns:
- filtered contacts or an empty list if none matched
-
getFirstPreferredType
public Contact getFirstPreferredType(ContactType type)
Get the first primaryContact
for the provided type.- Returns:
- first preferred type contact found or null if nothing were found
-
getCreators
public List<Contact> getCreators()
Get the list ofContact
of type ContactType.ORIGINATOR.- Returns:
- all creators found or empty list if none were found
-
getContacts
public List<Contact> getContacts()
Get the list ofContact
of type ContactType.ADMINISTRATIVE_POINT_OF_CONTACT.- Returns:
- all contacts found or empty list if none were found
-
getMetadataProviders
public List<Contact> getMetadataProviders()
Get the list ofContact
of type ContactType.METADATA_AUTHOR.- Returns:
- all metadataProviders found or empty list if none were found
-
getAllType
public List<Contact> getAllType(ContactType type)
Get allContact
for the provided type.- Returns:
- all
Contact
for specified type or empty list if none found
-
-