Java Code Examples for org.springframework.util.CollectionUtils#unmodifiableMultiValueMap()

The following examples show how to use org.springframework.util.CollectionUtils#unmodifiableMultiValueMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HierarchicalUriComponents.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Package-private constructor. All arguments are optional, and can be {@code null}.
 * @param scheme the scheme
 * @param userInfo the user info
 * @param host the host
 * @param port the port
 * @param path the path
 * @param queryParams the query parameters
 * @param fragment the fragment
 * @param encoded whether the components are already encoded
 * @param verify whether the components need to be checked for illegal characters
 */
HierarchicalUriComponents(String scheme, String userInfo, String host, String port,
		PathComponent path, MultiValueMap<String, String> queryParams,
		String fragment, boolean encoded, boolean verify) {

	super(scheme, fragment);
	this.userInfo = userInfo;
	this.host = host;
	this.port = port;
	this.path = path != null ? path : NULL_PATH_COMPONENT;
	this.queryParams = CollectionUtils.unmodifiableMultiValueMap(
			queryParams != null ? queryParams : new LinkedMultiValueMap<String, String>(0));
	this.encoded = encoded;
	if (verify) {
		verify();
	}
}
 
Example 2
Source File: JettyClientHttpResponse.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public MultiValueMap<String, ResponseCookie> getCookies() {
	MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>();
	List<String> cookieHeader = getHeaders().get(HttpHeaders.SET_COOKIE);
	if (cookieHeader != null) {
		cookieHeader.forEach(header -> {
			HttpCookie.parse(header)
					.forEach(cookie -> result.add(cookie.getName(),
							ResponseCookie.from(cookie.getName(), cookie.getValue())
					.domain(cookie.getDomain())
					.path(cookie.getPath())
					.maxAge(cookie.getMaxAge())
					.secure(cookie.getSecure())
					.httpOnly(cookie.isHttpOnly())
					.build()));
		});
	}
	return CollectionUtils.unmodifiableMultiValueMap(result);
}
 
Example 3
Source File: HierarchicalUriComponents.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Package-private constructor. All arguments are optional, and can be {@code null}.
 * @param scheme the scheme
 * @param userInfo the user info
 * @param host the host
 * @param port the port
 * @param path the path
 * @param query the query parameters
 * @param fragment the fragment
 * @param encoded whether the components are already encoded
 */
HierarchicalUriComponents(@Nullable String scheme, @Nullable String fragment, @Nullable String userInfo,
		@Nullable String host, @Nullable String port, @Nullable PathComponent path,
		@Nullable MultiValueMap<String, String> query, boolean encoded) {

	super(scheme, fragment);

	this.userInfo = userInfo;
	this.host = host;
	this.port = port;
	this.path = path != null ? path : NULL_PATH_COMPONENT;
	this.queryParams = query != null ? CollectionUtils.unmodifiableMultiValueMap(query) : EMPTY_QUERY_PARAMS;
	this.encodeState = encoded ? EncodeState.FULLY_ENCODED : EncodeState.RAW;

	// Check for illegal characters..
	if (encoded) {
		verify();
	}
}
 
Example 4
Source File: HierarchicalUriComponents.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Package-private constructor. All arguments are optional, and can be {@code null}.
 * @param scheme the scheme
 * @param userInfo the user info
 * @param host the host
 * @param port the port
 * @param path the path
 * @param query the query parameters
 * @param fragment the fragment
 * @param encoded whether the components are already encoded
 */
HierarchicalUriComponents(@Nullable String scheme, @Nullable String fragment, @Nullable String userInfo,
		@Nullable String host, @Nullable String port, @Nullable PathComponent path,
		@Nullable MultiValueMap<String, String> query, boolean encoded) {

	super(scheme, fragment);

	this.userInfo = userInfo;
	this.host = host;
	this.port = port;
	this.path = path != null ? path : NULL_PATH_COMPONENT;
	this.queryParams = query != null ? CollectionUtils.unmodifiableMultiValueMap(query) : EMPTY_QUERY_PARAMS;
	this.encodeState = encoded ? EncodeState.FULLY_ENCODED : EncodeState.RAW;

	// Check for illegal characters..
	if (encoded) {
		verify();
	}
}
 
Example 5
Source File: JettyClientHttpResponse.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public MultiValueMap<String, ResponseCookie> getCookies() {
	MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>();
	List<String> cookieHeader = getHeaders().get(HttpHeaders.SET_COOKIE);
	if (cookieHeader != null) {
		cookieHeader.forEach(header ->
			HttpCookie.parse(header)
					.forEach(cookie -> result.add(cookie.getName(),
							ResponseCookie.from(cookie.getName(), cookie.getValue())
					.domain(cookie.getDomain())
					.path(cookie.getPath())
					.maxAge(cookie.getMaxAge())
					.secure(cookie.getSecure())
					.httpOnly(cookie.isHttpOnly())
					.build()))
		);
	}
	return CollectionUtils.unmodifiableMultiValueMap(result);
}
 
Example 6
Source File: HierarchicalUriComponents.java    From java-technology-stack with MIT License 5 votes vote down vote up
private MultiValueMap<String, String> encodeQueryParams(BiFunction<String, Type, String> encoder) {
	int size = this.queryParams.size();
	MultiValueMap<String, String> result = new LinkedMultiValueMap<>(size);
	this.queryParams.forEach((key, values) -> {
		String name = encoder.apply(key, Type.QUERY_PARAM);
		List<String> encodedValues = new ArrayList<>(values.size());
		for (String value : values) {
			encodedValues.add(value != null ? encoder.apply(value, Type.QUERY_PARAM) : null);
		}
		result.put(name, encodedValues);
	});
	return CollectionUtils.unmodifiableMultiValueMap(result);
}
 
Example 7
Source File: DefaultPathContainer.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public DefaultPathSegment(String value, String valueToMatch, MultiValueMap<String, String> params) {
	Assert.isTrue(!value.contains("/"), () -> "Invalid path segment value: " + value);
	this.value = value;
	this.valueToMatch = valueToMatch;
	this.valueToMatchAsChars = valueToMatch.toCharArray();
	this.parameters = CollectionUtils.unmodifiableMultiValueMap(params);
}
 
Example 8
Source File: AbstractServerHttpRequest.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public MultiValueMap<String, HttpCookie> getCookies() {
	if (this.cookies == null) {
		this.cookies = CollectionUtils.unmodifiableMultiValueMap(initCookies());
	}
	return this.cookies;
}
 
Example 9
Source File: AbstractServerHttpRequest.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public MultiValueMap<String, String> getQueryParams() {
	if (this.queryParams == null) {
		this.queryParams = CollectionUtils.unmodifiableMultiValueMap(initQueryParams());
	}
	return this.queryParams;
}
 
Example 10
Source File: DefaultServerResponseBuilder.java    From java-technology-stack with MIT License 5 votes vote down vote up
protected AbstractServerResponse(
		int statusCode, HttpHeaders headers, MultiValueMap<String, ResponseCookie> cookies) {

	this.statusCode = statusCode;
	this.headers = HttpHeaders.readOnlyHttpHeaders(headers);
	this.cookies = CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(cookies));
}
 
Example 11
Source File: AbstractClientHttpRequest.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public MultiValueMap<String, HttpCookie> getCookies() {
	if (State.COMMITTED.equals(this.state.get())) {
		return CollectionUtils.unmodifiableMultiValueMap(this.cookies);
	}
	return this.cookies;
}
 
Example 12
Source File: HierarchicalUriComponents.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private MultiValueMap<String, String> encodeQueryParams(BiFunction<String, Type, String> encoder) {
	int size = this.queryParams.size();
	MultiValueMap<String, String> result = new LinkedMultiValueMap<>(size);
	this.queryParams.forEach((key, values) -> {
		String name = encoder.apply(key, Type.QUERY_PARAM);
		List<String> encodedValues = new ArrayList<>(values.size());
		for (String value : values) {
			encodedValues.add(value != null ? encoder.apply(value, Type.QUERY_PARAM) : null);
		}
		result.put(name, encodedValues);
	});
	return CollectionUtils.unmodifiableMultiValueMap(result);
}
 
Example 13
Source File: DefaultServerResponseBuilder.java    From spring-analysis-note with MIT License 5 votes vote down vote up
protected AbstractServerResponse(
		int statusCode, HttpHeaders headers, MultiValueMap<String, ResponseCookie> cookies,
		Map<String, Object> hints) {

	this.statusCode = statusCode;
	this.headers = HttpHeaders.readOnlyHttpHeaders(headers);
	this.cookies = CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(cookies));
	this.hints = hints;
}
 
Example 14
Source File: MockServerRequest.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public MultiValueMap<String, String> queryParams() {
	return CollectionUtils.unmodifiableMultiValueMap(this.queryParams);
}
 
Example 15
Source File: AbstractServerHttpResponse.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public MultiValueMap<String, ResponseCookie> getCookies() {
	return (this.state.get() == State.COMMITTED ?
			CollectionUtils.unmodifiableMultiValueMap(this.cookies) : this.cookies);
}
 
Example 16
Source File: AbstractServerHttpResponse.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public MultiValueMap<String, ResponseCookie> getCookies() {
	return (this.state.get() == State.COMMITTED ?
			CollectionUtils.unmodifiableMultiValueMap(this.cookies) : this.cookies);
}
 
Example 17
Source File: DefaultServerRequestBuilder.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static <K, V> MultiValueMap<K, V> unmodifiableCopy(MultiValueMap<K, V> original) {
	return CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(original));
}
 
Example 18
Source File: DefaultWebClientBuilder.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static <K, V> MultiValueMap<K, V> unmodifiableCopy(MultiValueMap<K, V> map) {
	return CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(map));
}
 
Example 19
Source File: MockServerRequest.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public MultiValueMap<String, String> queryParams() {
	return CollectionUtils.unmodifiableMultiValueMap(this.queryParams);
}
 
Example 20
Source File: AbstractMethodMessageHandler.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Return a read-only multi-value map with a direct lookup of mappings,
 * (e.g. for non-pattern destinations).
 */
public MultiValueMap<String, T> getDestinationLookup() {
	return CollectionUtils.unmodifiableMultiValueMap(this.destinationLookup);
}