io.github.itroadlabs.apicross.beanvalidation.springmvc.params.ParamNameDataBinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apicross-toolbox Show documentation
Show all versions of apicross-toolbox Show documentation
APICROSS utility classes library
The newest version!
package io.github.itroadlabs.apicross.beanvalidation.springmvc.params;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.web.servlet.mvc.method.annotation.ExtendedServletRequestDataBinder;
import java.util.Map;
public class ParamNameDataBinder extends ExtendedServletRequestDataBinder {
private final Map renameMapping;
public ParamNameDataBinder(Object target, String objectName, Map renameMapping) {
super(target, objectName);
this.renameMapping = renameMapping;
}
@Override
protected void addBindValues(MutablePropertyValues mpvs, jakarta.servlet.ServletRequest request) {
super.addBindValues(mpvs, request);
for (Map.Entry entry : renameMapping.entrySet()) {
String parameterName = entry.getKey();
String propertyName = entry.getValue();
if (mpvs.contains(parameterName)) {
mpvs.add(propertyName, mpvs.getPropertyValue(parameterName).getValue());
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy