本文整理汇总了Java中com.fasterxml.jackson.databind.JavaType.isContainerType方法的典型用法代码示例。如果您正苦于以下问题:Java JavaType.isContainerType方法的具体用法?Java JavaType.isContainerType怎么用?Java JavaType.isContainerType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.JavaType
的用法示例。
在下文中一共展示了JavaType.isContainerType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkType
import com.fasterxml.jackson.databind.JavaType; //导入方法依赖的package包/类
private void checkType(JavaType type) {
// 原子类型/string在java中是abstract的
if (type.getRawClass().isPrimitive()
|| propertyCreatorMap.containsKey(type.getRawClass())
|| String.class.equals(type.getRawClass())) {
return;
}
String msg = "Must be a concrete type.";
if (type.isMapLikeType()) {
Class<?> keyTypeClass = type.getKeyType().getRawClass();
if (!String.class.equals(keyTypeClass)) {
// swagger中map的key只允许为string
throw new Error("Type of key in map must be string, but got " + keyTypeClass.getName());
}
}
if (type.isContainerType()) {
checkType(type.getContentType());
return;
}
if (type.getRawClass().isInterface()) {
throw new ServiceCombException(type.getTypeName() + " is interface. " + msg);
}
if (Modifier.isAbstract(type.getRawClass().getModifiers())) {
throw new ServiceCombException(type.getTypeName() + " is abstract class. " + msg);
}
}
示例2: writeInternal
import com.fasterxml.jackson.databind.JavaType; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
protected void writeInternal(Object object, Type type, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
JsonEncoding encoding = getJsonEncoding(outputMessage.getHeaders().getContentType());
JsonGenerator generator = this.objectMapper.getFactory().createGenerator(outputMessage.getBody(), encoding);
try {
JavaType javaType = null;
if (jackson26Available && type != null && object != null && TypeUtils.isAssignable(type, object.getClass())) {
javaType = getJavaType(type, null);
}
ObjectWriter objectWriter;
objectWriter = this.objectMapper.writer();
if (javaType != null && javaType.isContainerType()) {
objectWriter = objectWriter.withType(javaType);
}
objectWriter.writeValue(generator, object);
generator.flush();
}
catch (JsonProcessingException ex) {
throw new HttpMessageNotWritableException("Could not write content: " + ex.getMessage(), ex);
}
}
开发者ID:JetBrains,项目名称:teamcity-hashicorp-vault-plugin,代码行数:28,代码来源:AbstractJackson2HttpMessageConverter.java