Browse Source

Polishing

pull/1397/head
Arjen Poutsma 8 years ago
parent
commit
03861df0ba
  1. 20
      spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java

20
spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -436,7 +436,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
} }
/** /**
* Initialize components of this {@link UriComponentsBuilder} from the * Initialize components of this {@code UriComponentsBuilder} from the
* components of the given {@link UriComponents}. * components of the given {@link UriComponents}.
* @param uriComponents the UriComponents instance * @param uriComponents the UriComponents instance
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
@ -453,6 +453,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param scheme the URI scheme * @param scheme the URI scheme
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder scheme(String scheme) { public UriComponentsBuilder scheme(String scheme) {
this.scheme = scheme; this.scheme = scheme;
return this; return this;
@ -478,6 +479,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param userInfo the URI user info * @param userInfo the URI user info
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder userInfo(String userInfo) { public UriComponentsBuilder userInfo(String userInfo) {
this.userInfo = userInfo; this.userInfo = userInfo;
resetSchemeSpecificPart(); resetSchemeSpecificPart();
@ -490,6 +492,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param host the URI host * @param host the URI host
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder host(String host) { public UriComponentsBuilder host(String host) {
this.host = host; this.host = host;
resetSchemeSpecificPart(); resetSchemeSpecificPart();
@ -501,6 +504,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param port the URI port * @param port the URI port
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder port(int port) { public UriComponentsBuilder port(int port) {
Assert.isTrue(port >= -1, "Port must be >= -1"); Assert.isTrue(port >= -1, "Port must be >= -1");
this.port = String.valueOf(port); this.port = String.valueOf(port);
@ -515,6 +519,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param port the URI port * @param port the URI port
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder port(String port) { public UriComponentsBuilder port(String port) {
this.port = port; this.port = port;
resetSchemeSpecificPart(); resetSchemeSpecificPart();
@ -527,6 +532,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param path the URI path * @param path the URI path
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder path(String path) { public UriComponentsBuilder path(String path) {
this.pathBuilder.addPath(path); this.pathBuilder.addPath(path);
resetSchemeSpecificPart(); resetSchemeSpecificPart();
@ -538,6 +544,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param path the URI path; a {@code null} value results in an empty path. * @param path the URI path; a {@code null} value results in an empty path.
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder replacePath(String path) { public UriComponentsBuilder replacePath(String path) {
this.pathBuilder = new CompositePathComponentBuilder(path); this.pathBuilder = new CompositePathComponentBuilder(path);
resetSchemeSpecificPart(); resetSchemeSpecificPart();
@ -551,6 +558,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param pathSegments the URI path segments * @param pathSegments the URI path segments
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder pathSegment(String... pathSegments) throws IllegalArgumentException { public UriComponentsBuilder pathSegment(String... pathSegments) throws IllegalArgumentException {
this.pathBuilder.addPathSegments(pathSegments); this.pathBuilder.addPathSegments(pathSegments);
resetSchemeSpecificPart(); resetSchemeSpecificPart();
@ -573,6 +581,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param query the query string * @param query the query string
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder query(String query) { public UriComponentsBuilder query(String query) {
if (query != null) { if (query != null) {
Matcher matcher = QUERY_PARAM_PATTERN.matcher(query); Matcher matcher = QUERY_PARAM_PATTERN.matcher(query);
@ -595,6 +604,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param query the query string; a {@code null} value removes all query parameters. * @param query the query string; a {@code null} value removes all query parameters.
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder replaceQuery(String query) { public UriComponentsBuilder replaceQuery(String query) {
this.queryParams.clear(); this.queryParams.clear();
query(query); query(query);
@ -611,6 +621,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param values the query parameter values * @param values the query parameter values
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder queryParam(String name, Object... values) { public UriComponentsBuilder queryParam(String name, Object... values) {
Assert.notNull(name, "Name must not be null"); Assert.notNull(name, "Name must not be null");
if (!ObjectUtils.isEmpty(values)) { if (!ObjectUtils.isEmpty(values)) {
@ -632,6 +643,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
* @since 4.0 * @since 4.0
*/ */
@Override
public UriComponentsBuilder queryParams(MultiValueMap<String, String> params) { public UriComponentsBuilder queryParams(MultiValueMap<String, String> params) {
if (params != null) { if (params != null) {
this.queryParams.putAll(params); this.queryParams.putAll(params);
@ -646,6 +658,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param values the query parameter values * @param values the query parameter values
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder replaceQueryParam(String name, Object... values) { public UriComponentsBuilder replaceQueryParam(String name, Object... values) {
Assert.notNull(name, "Name must not be null"); Assert.notNull(name, "Name must not be null");
this.queryParams.remove(name); this.queryParams.remove(name);
@ -662,6 +675,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
* @since 4.2 * @since 4.2
*/ */
@Override
public UriComponentsBuilder replaceQueryParams(MultiValueMap<String, String> params) { public UriComponentsBuilder replaceQueryParams(MultiValueMap<String, String> params) {
this.queryParams.clear(); this.queryParams.clear();
if (params != null) { if (params != null) {
@ -676,6 +690,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
* @param fragment the URI fragment * @param fragment the URI fragment
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
*/ */
@Override
public UriComponentsBuilder fragment(String fragment) { public UriComponentsBuilder fragment(String fragment) {
if (fragment != null) { if (fragment != null) {
Assert.hasLength(fragment, "Fragment must not be empty"); Assert.hasLength(fragment, "Fragment must not be empty");
@ -759,7 +774,6 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
/** /**
* Public declaration of Object's {@code clone()} method. * Public declaration of Object's {@code clone()} method.
* Delegates to {@link #cloneBuilder()}. * Delegates to {@link #cloneBuilder()}.
* @see Object#clone()
*/ */
@Override @Override
public Object clone() { public Object clone() {

Loading…
Cancel
Save