1818import androidx .annotation .NonNull ;
1919import androidx .core .util .ObjectsCompat ;
2020
21+ import com .amplifyframework .auth .AuthUserAttribute ;
2122import com .amplifyframework .auth .options .AuthConfirmSignInOptions ;
2223import com .amplifyframework .util .Immutable ;
2324
25+ import java .util .ArrayList ;
2426import java .util .HashMap ;
27+ import java .util .List ;
2528import java .util .Map ;
2629import java .util .Objects ;
2730
3033 */
3134public final class AWSCognitoAuthConfirmSignInOptions extends AuthConfirmSignInOptions {
3235 private final Map <String , String > metadata ;
36+ private final List <AuthUserAttribute > userAttributes ;
3337
3438 /**
3539 * Advanced options for confirming sign in.
3640 * @param metadata Additional custom attributes to be sent to the service such as information about the client
41+ * @param userAttributes A list of additional user attributes which should be
42+ * associated with this user on confirmSignIn.
3743 */
3844 protected AWSCognitoAuthConfirmSignInOptions (
39- Map <String , String > metadata
45+ Map <String , String > metadata ,
46+ List <AuthUserAttribute > userAttributes
4047 ) {
4148 this .metadata = metadata ;
49+ this .userAttributes = userAttributes ;
4250 }
4351
4452 /**
@@ -50,6 +58,15 @@ public Map<String, String> getMetadata() {
5058 return metadata ;
5159 }
5260
61+ /**
62+ * Get additional user attributes which should be associated with this user on confirmSignIn.
63+ * @return additional user attributes which should be associated with this user on confirmSignIn
64+ */
65+ @ NonNull
66+ public List <AuthUserAttribute > getUserAttributes () {
67+ return userAttributes ;
68+ }
69+
5370 /**
5471 * Get a builder object.
5572 * @return a builder object.
@@ -62,7 +79,8 @@ public static CognitoBuilder builder() {
6279 @ Override
6380 public int hashCode () {
6481 return ObjectsCompat .hash (
65- getMetadata ()
82+ getMetadata (),
83+ getUserAttributes ()
6684 );
6785 }
6886
@@ -74,14 +92,16 @@ public boolean equals(Object obj) {
7492 return false ;
7593 } else {
7694 AWSCognitoAuthConfirmSignInOptions authConfirmSignInOptions = (AWSCognitoAuthConfirmSignInOptions ) obj ;
77- return ObjectsCompat .equals (getMetadata (), authConfirmSignInOptions .getMetadata ());
95+ return ObjectsCompat .equals (getMetadata (), authConfirmSignInOptions .getMetadata ()) &&
96+ ObjectsCompat .equals (getUserAttributes (), authConfirmSignInOptions .getUserAttributes ());
7897 }
7998 }
8099
81100 @ Override
82101 public String toString () {
83102 return "AWSCognitoAuthConfirmSignInOptions{" +
84- "metadata=" + metadata +
103+ "userAttributes=" + getUserAttributes () +
104+ ", metadata=" + getMetadata () +
85105 '}' ;
86106 }
87107
@@ -90,13 +110,15 @@ public String toString() {
90110 */
91111 public static final class CognitoBuilder extends Builder <CognitoBuilder > {
92112 private Map <String , String > metadata ;
113+ private List <AuthUserAttribute > userAttributes ;
93114
94115 /**
95116 * Constructor for the builder.
96117 */
97118 public CognitoBuilder () {
98119 super ();
99120 this .metadata = new HashMap <>();
121+ this .userAttributes = new ArrayList <>();
100122 }
101123
102124 /**
@@ -121,14 +143,29 @@ public CognitoBuilder metadata(@NonNull Map<String, String> metadata) {
121143 return getThis ();
122144 }
123145
146+ /**
147+ * Set the userAttributes field for the object being built.
148+ * @param userAttributes A list of additional user attributes which should be
149+ * * associated with this user on confirmSignIn.
150+ * @return the instance of the builder.
151+ */
152+ @ NonNull
153+ public CognitoBuilder userAttributes (@ NonNull List <AuthUserAttribute > userAttributes ) {
154+ Objects .requireNonNull (userAttributes );
155+ this .userAttributes .clear ();
156+ this .userAttributes .addAll (userAttributes );
157+ return getThis ();
158+ }
159+
124160 /**
125161 * Construct and return the object with the values set in the builder.
126162 * @return a new instance of AWSCognitoAuthConfirmSignInOptions with the values specified in the builder.
127163 */
128164 @ NonNull
129165 public AWSCognitoAuthConfirmSignInOptions build () {
130166 return new AWSCognitoAuthConfirmSignInOptions (
131- Immutable .of (metadata ));
167+ Immutable .of (metadata ),
168+ Immutable .of (userAttributes ));
132169 }
133170 }
134171}
0 commit comments