3434 */
3535public class ParameterBuilder {
3636
37+ public static final String GRANT_TYPE_PASSWORD = "password" ;
38+ public static final String GRANT_TYPE_JWT = "urn:ietf:params:oauth:grant-type:jwt-bearer" ;
3739 public static final String SCOPE_OPENID = "openid" ;
3840 public static final String SCOPE_OFFLINE_ACCESS = "openid offline_access" ;
39- public static final String ACCESS_TOKEN = "access_token" ;
40- public static final String CONNECTION = "connection" ;
41- public static final String SEND = "send" ;
4241
43- public static final String GRANT_TYPE_PASSWORD = "password" ;
44- public static final String GRANT_TYPE_JWT = "urn:ietf:params:oauth:grant-type:jwt-bearer" ;
42+ private static final String ACCESS_TOKEN_KEY = "access_token" ;
43+ private static final String CONNECTION_KEY = "connection" ;
44+ private static final String SEND_KEY = "send" ;
45+ private static final String CLIENT_ID_KEY = "client_id" ;
46+ private static final String GRANT_TYPE_KEY = "grant_type" ;
47+ private static final String SCOPE_KEY = "scope" ;
48+ private static final String DEVICE_KEY = "device" ;
4549
4650 private Map <String , Object > parameters ;
4751
4852 /**
4953 * Creates a new builder
5054 */
51- public ParameterBuilder () {
55+ private ParameterBuilder () {
5256 this .parameters = new HashMap <>();
5357 setScope (SCOPE_OFFLINE_ACCESS );
5458 }
5559
5660 /**
5761 * Creates a new builder with default parameters
62+ *
5863 * @param parameters default parameters
5964 */
60- public ParameterBuilder (Map <String , Object > parameters ) {
65+ private ParameterBuilder (Map <String , Object > parameters ) {
6166 CheckHelper .checkArgument (parameters != null , "Must provide non-null parameters" );
6267 this .parameters = new HashMap <>(parameters );
6368 }
6469
6570 /**
6671 * Sets the 'client_id' parameter
72+ *
6773 * @param clientId clientID
6874 * @return itself
6975 */
7076 public ParameterBuilder setClientId (String clientId ) {
71- return set ("client_id" , clientId );
77+ return set (CLIENT_ID_KEY , clientId );
7278 }
7379
7480 /**
7581 * Sets the 'grant_type' parameter
82+ *
7683 * @param grantType grant type
7784 * @return itself
7885 */
7986 public ParameterBuilder setGrantType (String grantType ) {
80- return set ("grant_type" , grantType );
87+ return set (GRANT_TYPE_KEY , grantType );
8188 }
8289
8390 /**
8491 * Sets the 'connection' parameter
92+ *
8593 * @param connection name of the connection
8694 * @return itself
8795 */
8896 public ParameterBuilder setConnection (String connection ) {
89- return set (CONNECTION , connection );
97+ return set (CONNECTION_KEY , connection );
9098 }
9199
92100 /**
93101 * Sets the 'scope' parameter.
102+ *
94103 * @param scope a scope value
95104 * @return itself
96105 */
97106 public ParameterBuilder setScope (String scope ) {
98- return set ("scope" , scope );
107+ return set (SCOPE_KEY , scope );
99108 }
100109
101110 /**
102111 * Sets the 'device' parameter
112+ *
103113 * @param device a device name
104114 * @return itself
105115 */
106116 public ParameterBuilder setDevice (String device ) {
107- return set ("device" , device );
117+ return set (DEVICE_KEY , device );
108118 }
109119
110120 /**
111121 * Sets the 'access_token' parameter
122+ *
112123 * @param accessToken a access token
113124 * @return itself
114125 */
115126 public ParameterBuilder setAccessToken (String accessToken ) {
116- return set (ACCESS_TOKEN , accessToken );
127+ return set (ACCESS_TOKEN_KEY , accessToken );
117128 }
118129
119130 /**
120131 * Sets the 'send' parameter
132+ *
121133 * @param passwordlessType the type of passwordless login
122134 * @return itself
123135 */
124136 public ParameterBuilder setSend (PasswordlessType passwordlessType ) {
125137 switch (passwordlessType ) {
126138 default :
127139 case CODE :
128- return set (SEND , "code" );
140+ return set (SEND_KEY , "code" );
129141 case LINK :
130- return set (SEND , "link" );
142+ return set (SEND_KEY , "link" );
131143 case LINK_ANDROID :
132- return set (SEND , "link_android" );
144+ return set (SEND_KEY , "link_android" );
133145 case LINK_IOS :
134- return set (SEND , "link_ios" );
146+ return set (SEND_KEY , "link_ios" );
135147 }
136148 }
137149
138150 /**
139151 * Sets a parameter
140- * @param key parameter name
152+ *
153+ * @param key parameter name
141154 * @param value parameter value
142155 * @return itself
143156 */
@@ -148,6 +161,7 @@ public ParameterBuilder set(String key, Object value) {
148161
149162 /**
150163 * Adds all parameter from a map
164+ *
151165 * @param parameters map with parameters to add
152166 * @return itself
153167 */
@@ -160,6 +174,7 @@ public ParameterBuilder addAll(Map<String, Object> parameters) {
160174
161175 /**
162176 * Clears all existing parameters
177+ *
163178 * @return itself
164179 */
165180 public ParameterBuilder clearAll () {
@@ -169,6 +184,7 @@ public ParameterBuilder clearAll() {
169184
170185 /**
171186 * Create a {@link Map} with all the parameters
187+ *
172188 * @return a new map with the parameters
173189 */
174190 public Map <String , Object > asDictionary () {
@@ -177,6 +193,7 @@ public Map<String, Object> asDictionary() {
177193
178194 /**
179195 * Creates a new instance of the builder with default values
196+ *
180197 * @return a new builder
181198 */
182199 public static ParameterBuilder newBuilder () {
@@ -185,6 +202,7 @@ public static ParameterBuilder newBuilder() {
185202
186203 /**
187204 * Creates a new instance of the builder without any default values
205+ *
188206 * @return a new builder
189207 */
190208 public static ParameterBuilder newEmptyBuilder () {
@@ -193,6 +211,7 @@ public static ParameterBuilder newEmptyBuilder() {
193211
194212 /**
195213 * Creates a new instance of the builder with parameters.
214+ *
196215 * @param parameters default parameters
197216 * @return a new builder
198217 */
0 commit comments