@ -20,9 +20,7 @@ import java.net.URI;
@@ -20,9 +20,7 @@ import java.net.URI;
import java.nio.charset.Charset ;
import java.nio.charset.StandardCharsets ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Collection ;
import java.util.Collections ;
import java.util.HashMap ;
import java.util.LinkedList ;
import java.util.List ;
@ -34,7 +32,6 @@ import org.springframework.http.HttpHeaders;
@@ -34,7 +32,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest ;
import org.springframework.lang.Nullable ;
import org.springframework.util.Assert ;
import org.springframework.util.CollectionUtils ;
import org.springframework.util.LinkedMultiValueMap ;
import org.springframework.util.MultiValueMap ;
import org.springframework.util.ObjectUtils ;
@ -104,6 +101,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
@@ -104,6 +101,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
private static final Pattern FORWARDED_PROTO_PATTERN = Pattern . compile ( "proto=\"?([^;,\"]+)\"?" ) ;
private static final Object [ ] EMPTY_VALUES = new Object [ 0 ] ;
@Nullable
private String scheme ;
@ -700,11 +699,22 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
@@ -700,11 +699,22 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param name the query parameter name
* @param values the query parameter values
* @return this UriComponentsBuilder
* @see # queryParams ( String , Collection )
* @see # queryParam ( String , Collection )
* /
@Override
public UriComponentsBuilder queryParam ( String name , Object . . . values ) {
return queryParams ( name , ( ! ObjectUtils . isEmpty ( values ) ? Arrays . asList ( values ) : Collections . emptyList ( ) ) ) ;
Assert . notNull ( name , "Name must not be null" ) ;
if ( ! ObjectUtils . isEmpty ( values ) ) {
for ( Object value : values ) {
String valueAsString = ( value ! = null ? value . toString ( ) : null ) ;
this . queryParams . add ( name , valueAsString ) ;
}
}
else {
this . queryParams . add ( name , null ) ;
}
resetSchemeSpecificPart ( ) ;
return this ;
}
/ * *
@ -719,19 +729,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
@@ -719,19 +729,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @see # queryParam ( String , Object . . . )
* /
@Override
public UriComponentsBuilder queryParams ( String name , @Nullable Collection < ? > values ) {
Assert . notNull ( name , "Name must not be null" ) ;
if ( ! CollectionUtils . isEmpty ( values ) ) {
for ( Object value : values ) {
String valueAsString = ( value ! = null ? value . toString ( ) : null ) ;
this . queryParams . add ( name , valueAsString ) ;
}
}
else {
this . queryParams . add ( name , null ) ;
}
resetSchemeSpecificPart ( ) ;
return this ;
public UriComponentsBuilder queryParam ( String name , @Nullable Collection < ? > values ) {
return queryParam ( name , values ! = null ? values . toArray ( ) : EMPTY_VALUES ) ;
}
/ * *
@ -754,11 +753,17 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
@@ -754,11 +753,17 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param name the query parameter name
* @param values the query parameter values
* @return this UriComponentsBuilder
* @see # replaceQueryParams ( String , Collection )
* @see # replaceQueryParam ( String , Collection )
* /
@Override
public UriComponentsBuilder replaceQueryParam ( String name , Object . . . values ) {
return replaceQueryParams ( name , ( ! ObjectUtils . isEmpty ( values ) ? Arrays . asList ( values ) : Collections . emptyList ( ) ) ) ;
Assert . notNull ( name , "Name must not be null" ) ;
this . queryParams . remove ( name ) ;
if ( ! ObjectUtils . isEmpty ( values ) ) {
queryParam ( name , values ) ;
}
resetSchemeSpecificPart ( ) ;
return this ;
}
/ * *
@ -771,14 +776,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
@@ -771,14 +776,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @since 5 . 2 . 0
* /
@Override
public UriComponentsBuilder replaceQueryParams ( String name , @Nullable Collection < ? > values ) {
Assert . notNull ( name , "Name must not be null" ) ;
this . queryParams . remove ( name ) ;
if ( ! CollectionUtils . isEmpty ( values ) ) {
queryParams ( name , values ) ;
}
resetSchemeSpecificPart ( ) ;
return this ;
public UriComponentsBuilder replaceQueryParam ( String name , @Nullable Collection < ? > values ) {
return replaceQueryParam ( name , values ! = null ? values . toArray ( ) : EMPTY_VALUES ) ;
}
/ * *