io.katharsis.spring.SpringQueryParamsParserContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of katharsis-spring Show documentation
Show all versions of katharsis-spring Show documentation
Katharsis Spring integration
package io.katharsis.spring;
import io.katharsis.queryParams.context.AbstractQueryParamsParserContext;
import io.katharsis.queryParams.context.QueryParamsParserContext;
import io.katharsis.request.path.JsonPath;
import io.katharsis.resource.information.ResourceInformation;
import io.katharsis.resource.registry.ResourceRegistry;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
public class SpringQueryParamsParserContext extends AbstractQueryParamsParserContext {
private final Map> queryParameters = new HashMap<>();
SpringQueryParamsParserContext(HttpServletRequest request, ResourceRegistry resourceRegistry, JsonPath path) {
super(resourceRegistry, path);
initParameterMap(request);
}
@Override
public Set getParameterValue(String parameterName) {
if (queryParameters.containsKey(parameterName)) {
return queryParameters.get(parameterName);
}
return Collections.emptySet();
}
@Override
public Iterable getParameterNames() {
return queryParameters.keySet();
}
private void initParameterMap(HttpServletRequest request) {
Map params = request.getParameterMap();
for (Map.Entry entry : params.entrySet()) {
queryParameters.put(entry.getKey(), new HashSet<>(Arrays.asList(entry.getValue())));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy