@@ -45,44 +45,65 @@ public static IdentityMapV3Input fromHashedPhones(List<String> hashedPhones) {
4545 @ SerializedName ("phone_hash" )
4646 private final List <Identity > hashedPhones = new ArrayList <>();
4747
48- private IdentityMapV3Input () {}
48+ public IdentityMapV3Input () {}
4949
5050 public IdentityMapV3Input withHashedEmails (List <String > hashedEmails ) {
5151 for (String hashedEmail : hashedEmails ) {
52- this .hashedEmails .add (new Identity (hashedEmail ));
53- addToDiiMappings (hashedEmail , hashedEmail );
52+ withHashedEmail (hashedEmail );
5453 }
5554 return this ;
5655 }
5756
57+ public IdentityMapV3Input withHashedEmail (String hashedEmail ) {
58+ this .hashedEmails .add (new Identity (hashedEmail ));
59+ addToDiiMappings (hashedEmail , hashedEmail );
60+ return this ;
61+ }
62+
5863 public IdentityMapV3Input withHashedPhones (List <String > hashedPhones ) {
5964 for (String hashedPhone : hashedPhones ) {
60- this .hashedPhones .add (new Identity (hashedPhone ));
61- addToDiiMappings (hashedPhone , hashedPhone );
65+ withHashedPhone (hashedPhone );
6266 }
6367 return this ;
6468 }
6569
70+ public IdentityMapV3Input withHashedPhone (String hashedPhone ) {
71+ this .hashedPhones .add (new Identity (hashedPhone ));
72+ addToDiiMappings (hashedPhone , hashedPhone );
73+ return this ;
74+ }
75+
6676 public IdentityMapV3Input withEmails (List <String > emails ) {
6777 for (String email : emails ) {
68- String hash = InputUtil .normalizeAndHashEmail (email );
69- this .hashedEmails .add (new Identity (hash ));
70- addToDiiMappings (hash , email );
78+ withEmail (email );
7179 }
7280 return this ;
7381 }
7482
83+ public IdentityMapV3Input withEmail (String email ) {
84+ String hashedEmail = InputUtil .normalizeAndHashEmail (email );
85+ this .hashedEmails .add (new Identity (hashedEmail ));
86+ addToDiiMappings (hashedEmail , email );
87+ return this ;
88+ }
89+
7590 public IdentityMapV3Input withPhones (List <String > phones ) {
7691 for (String phone : phones ) {
77- if (!InputUtil .isPhoneNumberNormalized (phone )) {
78- throw new IllegalArgumentException ("phone number is not normalized: " + phone );
79- }
92+ withPhone (phone );
93+ }
94+ return this ;
95+ }
8096
81- String hash = InputUtil . getBase64EncodedHash ( phone );
82- this . hashedPhones . add ( new Identity ( hash ));
83- addToDiiMappings ( hash , phone );
97+ public IdentityMapV3Input withPhone ( String phone ) {
98+ if (! InputUtil . isPhoneNumberNormalized ( phone )) {
99+ throw new IllegalArgumentException ( "phone number is not normalized: " + phone );
84100 }
101+
102+ String hashedPhone = InputUtil .getBase64EncodedHash (phone );
103+ this .hashedPhones .add (new Identity (hashedPhone ));
104+ addToDiiMappings (hashedPhone , phone );
85105 return this ;
106+
86107 }
87108
88109 private void addToDiiMappings (String hashedDii , String rawDii ) {
0 commit comments