Java Code Examples for org.springframework.util.MultiValueMap#addAll()

The following examples show how to use org.springframework.util.MultiValueMap#addAll() . 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: CaptureTheRestPathElement.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public boolean matches(int pathIndex, MatchingContext matchingContext) {
	// No need to handle 'match start' checking as this captures everything
	// anyway and cannot be followed by anything else
	// assert next == null

	// If there is more data, it must start with the separator
	if (pathIndex < matchingContext.pathLength && !matchingContext.isSeparator(pathIndex)) {
		return false;
	}
	if (matchingContext.determineRemainingPath) {
		matchingContext.remainingPathIndex = matchingContext.pathLength;
	}
	if (matchingContext.extractingVariables) {
		// Collect the parameters from all the remaining segments
		MultiValueMap<String,String> parametersCollector = null;
		for (int i = pathIndex; i < matchingContext.pathLength; i++) {
			Element element = matchingContext.pathElements.get(i);
			if (element instanceof PathSegment) {
				MultiValueMap<String, String> parameters = ((PathSegment) element).parameters();
				if (!parameters.isEmpty()) {
					if (parametersCollector == null) {
						parametersCollector = new LinkedMultiValueMap<>();
					}
					parametersCollector.addAll(parameters);
				}
			}
		}
		matchingContext.set(this.variableName, pathToString(pathIndex, matchingContext.pathElements),
				parametersCollector == null?NO_PARAMETERS:parametersCollector);
	}
	return true;
}
 
Example 2
Source File: CaptureTheRestPathElement.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public boolean matches(int pathIndex, MatchingContext matchingContext) {
	// No need to handle 'match start' checking as this captures everything
	// anyway and cannot be followed by anything else
	// assert next == null

	// If there is more data, it must start with the separator
	if (pathIndex < matchingContext.pathLength && !matchingContext.isSeparator(pathIndex)) {
		return false;
	}
	if (matchingContext.determineRemainingPath) {
		matchingContext.remainingPathIndex = matchingContext.pathLength;
	}
	if (matchingContext.extractingVariables) {
		// Collect the parameters from all the remaining segments
		MultiValueMap<String,String> parametersCollector = null;
		for (int i = pathIndex; i < matchingContext.pathLength; i++) {
			Element element = matchingContext.pathElements.get(i);
			if (element instanceof PathSegment) {
				MultiValueMap<String, String> parameters = ((PathSegment) element).parameters();
				if (!parameters.isEmpty()) {
					if (parametersCollector == null) {
						parametersCollector = new LinkedMultiValueMap<>();
					}
					parametersCollector.addAll(parameters);
				}
			}
		}
		matchingContext.set(this.variableName, pathToString(pathIndex, matchingContext.pathElements),
				parametersCollector == null?NO_PARAMETERS:parametersCollector);
	}
	return true;
}
 
Example 3
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * To test enum parameters
 * To test enum parameters
 * <p><b>400</b> - Invalid request
 * <p><b>404</b> - Not found
 * @param enumHeaderStringArray Header parameter enum test (string array)
 * @param enumHeaderString Header parameter enum test (string)
 * @param enumQueryStringArray Query parameter enum test (string array)
 * @param enumQueryString Query parameter enum test (string)
 * @param enumQueryInteger Query parameter enum test (double)
 * @param enumQueryDouble Query parameter enum test (double)
 * @param enumFormStringArray Form parameter enum test (string array)
 * @param enumFormString Form parameter enum test (string)
 * @throws WebClientResponseException if an error occurs while attempting to invoke the API
 */
public Mono<Void> testEnumParameters(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List<String> enumFormStringArray, String enumFormString) throws WebClientResponseException {
    Object postBody = null;
    // create path and map variables
    final Map<String, Object> pathParams = new HashMap<String, Object>();

    final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
    final HttpHeaders headerParams = new HttpHeaders();
    final MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
    final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

    queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("csv".toUpperCase(Locale.ROOT)), "enum_query_string_array", enumQueryStringArray));
    queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_string", enumQueryString));
    queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_integer", enumQueryInteger));
    queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_double", enumQueryDouble));

    if (enumHeaderStringArray != null)
    headerParams.add("enum_header_string_array", apiClient.parameterToString(enumHeaderStringArray));
    if (enumHeaderString != null)
    headerParams.add("enum_header_string", apiClient.parameterToString(enumHeaderString));
    if (enumFormStringArray != null)
        formParams.addAll("enum_form_string_array", enumFormStringArray);
    if (enumFormString != null)
        formParams.add("enum_form_string", enumFormString);

    final String[] localVarAccepts = { };
    final List<MediaType> localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    final String[] localVarContentTypes = { 
        "application/x-www-form-urlencoded"
    };
    final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[] {  };

    ParameterizedTypeReference<Void> localVarReturnType = new ParameterizedTypeReference<Void>() {};
    return apiClient.invokeAPI("/fake", HttpMethod.GET, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
 
Example 4
Source File: RSQLComplexConverter.java    From rsql-jpa-specification with MIT License 5 votes vote down vote up
@Override
public Void visit(ComparisonNode node, Map<String, MultiValueMap<String, String>> map) {
	log.debug("visit(node:{},map:{})", node, map);
	String key = node.getSelector();
	ComparisonOperator operator = node.getOperator();
	MultiValueMap<String, String> operatorMap = map.computeIfAbsent(key, k -> CollectionUtils.toMultiValueMap(new HashMap<>()));
	for (String ops : operator.getSymbols()) {
		operatorMap.addAll(ops, node.getArguments());
	}
	return null;
}
 
Example 5
Source File: MergedAnnotationCollectors.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static <K, V> MultiValueMap<K, V> merge(MultiValueMap<K, V> map,
		MultiValueMap<K, V> additions) {
	map.addAll(additions);
	return map;
}
 
Example 6
Source File: RSQLSimpleConverter.java    From rsql-jpa-specification with MIT License 4 votes vote down vote up
@Override
public Void visit(ComparisonNode node, MultiValueMap<String, String> map) {
	log.debug("visit(node:{},map:{})", node, map);
	map.addAll(node.getSelector(), node.getArguments());
	return null;
}