7171 * @see java.net.URL
7272 * @see java.net.URI
7373 */
74- public /** final**/
74+ public /*final**/
7575class URL implements Serializable {
7676
7777 private static final long serialVersionUID = -1985165475234910535L ;
@@ -166,9 +166,9 @@ public URL(String protocol, String username, String password, String host, int p
166166 }
167167 this .path = path ;
168168 if (parameters == null ) {
169- parameters = new HashMap <String , String >();
169+ parameters = new HashMap <>();
170170 } else {
171- parameters = new HashMap <String , String >(parameters );
171+ parameters = new HashMap <>(parameters );
172172 }
173173 this .parameters = Collections .unmodifiableMap (parameters );
174174 }
@@ -191,10 +191,10 @@ public static URL valueOf(String url) {
191191 int port = 0 ;
192192 String path = null ;
193193 Map <String , String > parameters = null ;
194- int i = url .indexOf ("?" ); // seperator between body and parameters
194+ int i = url .indexOf ("?" ); // separator between body and parameters
195195 if (i >= 0 ) {
196- String [] parts = url .substring (i + 1 ).split ("\\ &" );
197- parameters = new HashMap <String , String >();
196+ String [] parts = url .substring (i + 1 ).split ("&" );
197+ parameters = new HashMap <>();
198198 for (String part : parts ) {
199199 part = part .trim ();
200200 if (part .length () > 0 ) {
@@ -265,7 +265,7 @@ public static URL valueOf(String url, String... reserveParams) {
265265 if (reserveParams == null || reserveParams .length == 0 ) {
266266 return result ;
267267 }
268- Map <String , String > newMap = new HashMap <String , String >(reserveParams .length );
268+ Map <String , String > newMap = new HashMap <>(reserveParams .length );
269269 Map <String , String > oldMap = result .getParameters ();
270270 for (String reserveParam : reserveParams ) {
271271 String tmp = oldMap .get (reserveParam );
@@ -277,7 +277,7 @@ public static URL valueOf(String url, String... reserveParams) {
277277 }
278278
279279 public static URL valueOf (URL url , String [] reserveParams , String [] reserveParamPrefixs ) {
280- Map <String , String > newMap = new HashMap <String , String >();
280+ Map <String , String > newMap = new HashMap <>();
281281 Map <String , String > oldMap = url .getParameters ();
282282 if (reserveParamPrefixs != null && reserveParamPrefixs .length != 0 ) {
283283 for (Map .Entry <String , String > entry : oldMap .entrySet ()) {
@@ -425,7 +425,7 @@ public String getBackupAddress(int defaultPort) {
425425 }
426426
427427 public List <URL > getBackupUrls () {
428- List <URL > urls = new ArrayList <URL >();
428+ List <URL > urls = new ArrayList <>();
429429 urls .add (this );
430430 String [] backups = getParameter (Constants .BACKUP_KEY , new String [0 ]);
431431 if (backups != null && backups .length > 0 ) {
@@ -510,14 +510,14 @@ public List<String> getParameter(String key, List<String> defaultValue) {
510510
511511 private Map <String , Number > getNumbers () {
512512 if (numbers == null ) { // concurrent initialization is tolerant
513- numbers = new ConcurrentHashMap <String , Number >();
513+ numbers = new ConcurrentHashMap <>();
514514 }
515515 return numbers ;
516516 }
517517
518518 private Map <String , URL > getUrls () {
519519 if (urls == null ) { // concurrent initialization is tolerant
520- urls = new ConcurrentHashMap <String , URL >();
520+ urls = new ConcurrentHashMap <>();
521521 }
522522 return urls ;
523523 }
@@ -1004,7 +1004,7 @@ public URL addParameter(String key, String value) {
10041004 return this ;
10051005 }
10061006
1007- Map <String , String > map = new HashMap <String , String >(getParameters ());
1007+ Map <String , String > map = new HashMap <>(getParameters ());
10081008 map .put (key , value );
10091009 return new URL (protocol , username , password , host , port , path , map );
10101010 }
@@ -1017,7 +1017,7 @@ public URL addParameterIfAbsent(String key, String value) {
10171017 if (hasParameter (key )) {
10181018 return this ;
10191019 }
1020- Map <String , String > map = new HashMap <String , String >(getParameters ());
1020+ Map <String , String > map = new HashMap <>(getParameters ());
10211021 map .put (key , value );
10221022 return new URL (protocol , username , password , host , port , path , map );
10231023 }
@@ -1053,7 +1053,7 @@ public URL addParameters(Map<String, String> parameters) {
10531053 return this ;
10541054 }
10551055
1056- Map <String , String > map = new HashMap <String , String >(getParameters ());
1056+ Map <String , String > map = new HashMap <>(getParameters ());
10571057 map .putAll (parameters );
10581058 return new URL (protocol , username , password , host , port , path , map );
10591059 }
@@ -1062,7 +1062,7 @@ public URL addParametersIfAbsent(Map<String, String> parameters) {
10621062 if (CollectionUtils .isEmptyMap (parameters )) {
10631063 return this ;
10641064 }
1065- Map <String , String > map = new HashMap <String , String >(parameters );
1065+ Map <String , String > map = new HashMap <>(parameters );
10661066 map .putAll (getParameters ());
10671067 return new URL (protocol , username , password , host , port , path , map );
10681068 }
@@ -1074,7 +1074,7 @@ public URL addParameters(String... pairs) {
10741074 if (pairs .length % 2 != 0 ) {
10751075 throw new IllegalArgumentException ("Map pairs can not be odd number." );
10761076 }
1077- Map <String , String > map = new HashMap <String , String >();
1077+ Map <String , String > map = new HashMap <>();
10781078 int len = pairs .length / 2 ;
10791079 for (int i = 0 ; i < len ; i ++) {
10801080 map .put (pairs [2 * i ], pairs [2 * i + 1 ]);
@@ -1107,7 +1107,7 @@ public URL removeParameters(String... keys) {
11071107 if (keys == null || keys .length == 0 ) {
11081108 return this ;
11091109 }
1110- Map <String , String > map = new HashMap <String , String >(getParameters ());
1110+ Map <String , String > map = new HashMap <>(getParameters ());
11111111 for (String key : keys ) {
11121112 map .remove (key );
11131113 }
@@ -1118,7 +1118,7 @@ public URL removeParameters(String... keys) {
11181118 }
11191119
11201120 public URL clearParameters () {
1121- return new URL (protocol , username , password , host , port , path , new HashMap <String , String >());
1121+ return new URL (protocol , username , password , host , port , path , new HashMap <>());
11221122 }
11231123
11241124 public String getRawParameter (String key ) {
@@ -1144,7 +1144,7 @@ public String getRawParameter(String key) {
11441144 }
11451145
11461146 public Map <String , String > toMap () {
1147- Map <String , String > map = new HashMap <String , String >(parameters );
1147+ Map <String , String > map = new HashMap <>(parameters );
11481148 if (protocol != null ) {
11491149 map .put (Constants .PROTOCOL_KEY , protocol );
11501150 }
@@ -1217,7 +1217,7 @@ private void buildParameters(StringBuilder buf, boolean concat, String[] paramet
12171217 if (CollectionUtils .isNotEmptyMap (getParameters ())) {
12181218 List <String > includes = (ArrayUtils .isEmpty (parameters ) ? null : Arrays .asList (parameters ));
12191219 boolean first = true ;
1220- for (Map .Entry <String , String > entry : new TreeMap <String , String >(getParameters ()).entrySet ()) {
1220+ for (Map .Entry <String , String > entry : new TreeMap <>(getParameters ()).entrySet ()) {
12211221 if (entry .getKey () != null && entry .getKey ().length () > 0
12221222 && (includes == null || includes .contains (entry .getKey ()))) {
12231223 if (first ) {
0 commit comments