11package com .onelogin .saml2 .model ;
22
3+ import java .util .Arrays ;
4+ import java .util .Collections ;
5+ import java .util .List ;
36
47/**
58 * Contact class of OneLogin's Java Toolkit.
811 */
912public class Contact {
1013 /**
11- * Contact type
12- */
14+ * Contact type
15+ */
1316 private final String contactType ;
1417
1518 /**
16- * Contact given name
17- */
19+ * Contact company
20+ */
21+ private final String company ;
22+
23+ /**
24+ * Contact given name
25+ */
1826 private final String givenName ;
27+
28+ /**
29+ * Contact surname
30+ */
31+ private final String surName ;
1932
2033 /**
21- * Contact email
22- */
23- private final String emailAddress ;
34+ * Contact email
35+ */
36+ private final List < String > emailAddresses ;
2437
2538 /**
26- * Constructor
39+ * Contact phone number
40+ */
41+ private final List <String > telephoneNumbers ;
42+
43+ /**
44+ * Constructor to specify minimal contact data.
45+ * <p>
46+ * To maintain backward compatibility, a <code>null</code> given name and a
47+ * <code>null</code> e-mail address are handled as being empty strings.
2748 *
2849 * @param contactType
29- * String. Contact type
50+ * Contact type
3051 * @param givenName
31- * String. Contact given name
52+ * Contact given name
3253 * @param emailAddress
33- * String. Contact email
54+ * Contact e-mail
55+ * @deprecated use {@link #Contact(String, String, String, String, List, List)}
3456 */
57+ @ Deprecated
3558 public Contact (String contactType , String givenName , String emailAddress ) {
59+ this (contactType , null , givenName != null ? givenName : "" , null ,
60+ Arrays .asList (emailAddress != null ? emailAddress : "" ), null );
61+ }
62+
63+ /**
64+ * Constructor
65+ *
66+ * @param contactType
67+ * Contact type
68+ * @param givenName
69+ * Contact given name
70+ * @param surName
71+ * Contact surname
72+ * @param company
73+ * Contact company
74+ * @param emailAddresses
75+ * Contact e-mails
76+ * @param telephoneNumbers
77+ * Contact phone numbers
78+ */
79+ public Contact (String contactType , String company , String givenName , String surName , List <String > emailAddresses , List <String > telephoneNumbers ) {
3680 this .contactType = contactType != null ? contactType : "" ;
37- this .givenName = givenName != null ? givenName : "" ;
38- this .emailAddress = emailAddress != null ? emailAddress : "" ;
81+ this .company = company ;
82+ this .givenName = givenName ;
83+ this .surName = surName ;
84+ this .emailAddresses = emailAddresses != null ? emailAddresses : Collections .emptyList ();
85+ this .telephoneNumbers = telephoneNumbers != null ? telephoneNumbers : Collections .emptyList ();
3986 }
4087
4188 /**
@@ -46,17 +93,46 @@ public final String getContactType() {
4693 }
4794
4895 /**
49- * @return string the contact email
96+ * @return the contact email
97+ * @deprecated this returns just the first e-mail address in {@link #getEmailAddresses()}
5098 */
99+ @ Deprecated
51100 public final String getEmailAddress () {
52- return emailAddress ;
101+ return emailAddresses . size () > 0 ? emailAddresses . get ( 0 ): null ;
53102 }
54103
55104 /**
56- * @return string the contact given name
105+ * @return a list containing the contact e-mail addresses (never <code>null</code>)
106+ */
107+ public final List <String > getEmailAddresses () {
108+ return emailAddresses ;
109+ }
110+
111+ /**
112+ * @return the contact given name
57113 */
58114 public final String getGivenName () {
59115 return givenName ;
60116 }
117+
118+ /**
119+ * @return the contact surname
120+ */
121+ public final String getSurName () {
122+ return surName ;
123+ }
124+
125+ /**
126+ * @return the contact company
127+ */
128+ public final String getCompany () {
129+ return company ;
130+ }
61131
132+ /**
133+ * @return a list containing the contact phone numbers (never <code>null</code>)
134+ */
135+ public final List <String > getTelephoneNumbers () {
136+ return telephoneNumbers ;
137+ }
62138}
0 commit comments