本文整理匯總了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