Java源码示例:io.swagger.models.parameters.CookieParameter
示例1
protected Parameter createParameter(HttpParameterType httpParameterType) {
switch (httpParameterType) {
case PATH:
return new PathParameter();
case QUERY:
return new QueryParameter();
case HEADER:
return new HeaderParameter();
case FORM:
return new FormParameter();
case COOKIE:
return new CookieParameter();
case BODY:
return new BodyParameter();
default:
throw new IllegalStateException("not support httpParameterType " + httpParameterType);
}
}
示例2
@Override
public ParamValueProcessor create(Parameter parameter, Type genericParamType) {
JavaType targetType =
genericParamType == null ? null : TypeFactory.defaultInstance().constructType(genericParamType);
return new CookieProcessor(parameter.getName(), targetType, ((CookieParameter) parameter).getDefaultValue(),
parameter.getRequired());
}
示例3
@Test
public void testCreate() {
ParamValueProcessorCreator creator =
ParamValueProcessorCreatorManager.INSTANCE.findValue(CookieProcessorCreator.PARAMTYPE);
CookieParameter p = new CookieParameter();
p.setName("p1");
ParamValueProcessor processor = creator.create(p, String.class);
Assert.assertEquals(CookieProcessor.class, processor.getClass());
}