31
31
32
32
/**
33
33
* Parse a {@link String} to a Collection of {@link MongoCredential}.
34
- *
34
+ *
35
35
* @author Christoph Strobl
36
36
* @author Oliver Gierke
37
37
* @since 1.7
@@ -41,10 +41,10 @@ public class MongoCredentialPropertyEditor extends PropertyEditorSupport {
41
41
private static final Pattern GROUP_PATTERN = Pattern .compile ("(\\ \\ ?')(.*?)\\ 1" );
42
42
43
43
private static final String AUTH_MECHANISM_KEY = "uri.authMechanism" ;
44
- private static final String USERNAME_PASSWORD_DELIMINATOR = ":" ;
45
- private static final String DATABASE_DELIMINATOR = "@" ;
46
- private static final String OPTIONS_DELIMINATOR = "?" ;
47
- private static final String OPTION_VALUE_DELIMINATOR = "&" ;
44
+ private static final String USERNAME_PASSWORD_DELIMITER = ":" ;
45
+ private static final String DATABASE_DELIMITER = "@" ;
46
+ private static final String OPTIONS_DELIMITER = "?" ;
47
+ private static final String OPTION_VALUE_DELIMITER = "&" ;
48
48
49
49
/*
50
50
* (non-Javadoc)
@@ -57,7 +57,7 @@ public void setAsText(String text) throws IllegalArgumentException {
57
57
return ;
58
58
}
59
59
60
- List <MongoCredential > credentials = new ArrayList <MongoCredential >();
60
+ List <MongoCredential > credentials = new ArrayList <>();
61
61
62
62
for (String credentialString : extractCredentialsString (text )) {
63
63
@@ -117,7 +117,7 @@ public void setAsText(String text) throws IllegalArgumentException {
117
117
private List <String > extractCredentialsString (String source ) {
118
118
119
119
Matcher matcher = GROUP_PATTERN .matcher (source );
120
- List <String > list = new ArrayList <String >();
120
+ List <String > list = new ArrayList <>();
121
121
122
122
while (matcher .find ()) {
123
123
@@ -134,44 +134,44 @@ private List<String> extractCredentialsString(String source) {
134
134
135
135
private static String [] extractUserNameAndPassword (String text ) {
136
136
137
- int index = text .lastIndexOf (DATABASE_DELIMINATOR );
137
+ int index = text .lastIndexOf (DATABASE_DELIMITER );
138
138
139
- index = index != -1 ? index : text .lastIndexOf (OPTIONS_DELIMINATOR );
139
+ index = index != -1 ? index : text .lastIndexOf (OPTIONS_DELIMITER );
140
140
141
141
if (index == -1 ) {
142
142
return new String [] {};
143
143
}
144
144
145
- return Arrays .asList (text .substring (0 , index ).split (USERNAME_PASSWORD_DELIMINATOR )). stream ( )
145
+ return Arrays .stream (text .substring (0 , index ).split (USERNAME_PASSWORD_DELIMITER ) )
146
146
.map (MongoCredentialPropertyEditor ::decodeParameter ).toArray (String []::new );
147
147
}
148
148
149
149
private static String extractDB (String text ) {
150
150
151
- int dbSeperationIndex = text .lastIndexOf (DATABASE_DELIMINATOR );
151
+ int dbSeparationIndex = text .lastIndexOf (DATABASE_DELIMITER );
152
152
153
- if (dbSeperationIndex == -1 ) {
153
+ if (dbSeparationIndex == -1 ) {
154
154
return "" ;
155
155
}
156
156
157
- String tmp = text .substring (dbSeperationIndex + 1 );
158
- int optionsSeperationIndex = tmp .lastIndexOf (OPTIONS_DELIMINATOR );
157
+ String tmp = text .substring (dbSeparationIndex + 1 );
158
+ int optionsSeparationIndex = tmp .lastIndexOf (OPTIONS_DELIMITER );
159
159
160
- return optionsSeperationIndex > -1 ? tmp .substring (0 , optionsSeperationIndex ) : tmp ;
160
+ return optionsSeparationIndex > -1 ? tmp .substring (0 , optionsSeparationIndex ) : tmp ;
161
161
}
162
162
163
163
private static Properties extractOptions (String text ) {
164
164
165
- int optionsSeperationIndex = text .lastIndexOf (OPTIONS_DELIMINATOR );
166
- int dbSeperationIndex = text .lastIndexOf (OPTIONS_DELIMINATOR );
165
+ int optionsSeparationIndex = text .lastIndexOf (OPTIONS_DELIMITER );
166
+ int dbSeparationIndex = text .lastIndexOf (OPTIONS_DELIMITER );
167
167
168
- if (optionsSeperationIndex == -1 || dbSeperationIndex > optionsSeperationIndex ) {
168
+ if (optionsSeparationIndex == -1 || dbSeparationIndex > optionsSeparationIndex ) {
169
169
return new Properties ();
170
170
}
171
171
172
172
Properties properties = new Properties ();
173
173
174
- for (String option : text .substring (optionsSeperationIndex + 1 ).split (OPTION_VALUE_DELIMINATOR )) {
174
+ for (String option : text .substring (optionsSeparationIndex + 1 ).split (OPTION_VALUE_DELIMITER )) {
175
175
String [] optionArgs = option .split ("=" );
176
176
properties .put (optionArgs [0 ], optionArgs [1 ]);
177
177
}
0 commit comments