use of com.dtflys.forest.mapping.MappingVariable in project forest by dromara.
the class JSONQueryLifeCycle method onParameterInitialized.
@Override
public void onParameterInitialized(ForestMethod method, MappingParameter parameter, JSONQuery annotation) {
String name = annotation.value();
parameter.setTarget(TARGET_QUERY);
parameter.setJsonParam(true);
if (StringUtils.isNotEmpty(name)) {
parameter.setName(name);
MappingVariable variable = new MappingVariable(name, parameter.getType());
variable.setIndex(parameter.getIndex());
method.addVariable(annotation.value(), variable);
parameter.setObjectProperties(false);
} else if (CharSequence.class.isAssignableFrom(parameter.getType())) {
parameter.setName(null);
parameter.setObjectProperties(false);
} else {
parameter.setObjectProperties(true);
}
method.addNamedParameter(parameter);
}
use of com.dtflys.forest.mapping.MappingVariable in project forest by dromara.
the class VariableLifeCycle method onParameterInitialized.
@Override
public void onParameterInitialized(ForestMethod method, MappingParameter parameter, Annotation annotation) {
Map<String, Object> attrs = ReflectUtils.getAttributesFromAnnotation(annotation);
String name = (String) attrs.get("value");
if (StringUtils.isEmpty(name)) {
name = parameter.getName();
}
String filterName = (String) attrs.get("filter");
MappingVariable variable = new MappingVariable(name, parameter.getType());
method.processParameterFilter(variable, filterName);
variable.setIndex(parameter.getIndex());
method.addVariable(name, variable);
}
use of com.dtflys.forest.mapping.MappingVariable in project forest by dromara.
the class DataParamLifeCycle method onParameterInitialized.
@Override
public void onParameterInitialized(ForestMethod method, MappingParameter parameter, DataParam annotation) {
String name = annotation.value();
String filterName = annotation.filter();
parameter.setName(name);
method.processParameterFilter(parameter, filterName);
method.addNamedParameter(parameter);
MappingVariable variable = new MappingVariable(name, parameter.getType());
method.processParameterFilter(variable, filterName);
variable.setIndex(parameter.getIndex());
method.addVariable(annotation.value(), variable);
}
use of com.dtflys.forest.mapping.MappingVariable in project forest by dromara.
the class AbstractBodyLifeCycle method onParameterInitialized.
@Override
public void onParameterInitialized(ForestMethod method, MappingParameter parameter, A annotation) {
Map<String, Object> attrs = ReflectUtils.getAttributesFromAnnotation(annotation);
String name = (String) attrs.get("name");
String filterName = (String) attrs.get("filter");
String partContentType = (String) attrs.get("partContentType");
String defaultValue = (String) attrs.get("defaultValue");
if (StringUtils.isNotEmpty(name)) {
parameter.setName(name);
MappingVariable variable = new MappingVariable(name, parameter.getType());
variable.setIndex(parameter.getIndex());
method.addVariable(name, variable);
parameter.setObjectProperties(false);
} else {
parameter.setObjectProperties(true);
}
if (StringUtils.isNotBlank(partContentType)) {
parameter.setPartContentType(partContentType.trim());
}
if (StringUtils.isNotEmpty(defaultValue)) {
parameter.setDefaultValue(defaultValue);
}
method.processParameterFilter(parameter, filterName);
parameter.setTarget(MappingParameter.TARGET_BODY);
method.addNamedParameter(parameter);
}
use of com.dtflys.forest.mapping.MappingVariable in project forest by dromara.
the class HeaderLifeCycle method onParameterInitialized.
@Override
public void onParameterInitialized(ForestMethod method, MappingParameter parameter, Header annotation) {
Map<String, Object> attrs = ReflectUtils.getAttributesFromAnnotation(annotation);
String defaultValue = (String) attrs.get("defaultValue");
String name = (String) attrs.get("name");
if (StringUtils.isNotEmpty(name)) {
parameter.setName(name);
MappingVariable variable = new MappingVariable(name, parameter.getType());
variable.setIndex(parameter.getIndex());
method.addVariable(name, variable);
parameter.setObjectProperties(false);
} else {
parameter.setObjectProperties(true);
}
if (StringUtils.isNotEmpty(defaultValue)) {
parameter.setDefaultValue(defaultValue);
}
parameter.setTarget(MappingParameter.TARGET_HEADER);
method.addNamedParameter(parameter);
}
Aggregations