本文整理汇总了Java中com.fasterxml.jackson.databind.type.TypeFactory.constructType方法的典型用法代码示例。如果您正苦于以下问题:Java TypeFactory.constructType方法的具体用法?Java TypeFactory.constructType怎么用?Java TypeFactory.constructType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.type.TypeFactory
的用法示例。
在下文中一共展示了TypeFactory.constructType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadProps
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
<T> Map<String, T> loadProps(Class<?> clazz, Function<KvProperty, T> func) {
ImmutableMap.Builder<String, T> b = ImmutableMap.builder();
TypeFactory tf = TypeFactory.defaultInstance();
while(clazz != null && !Object.class.equals(clazz)) {
for(Field field: clazz.getDeclaredFields()) {
KvMapping mapping = field.getAnnotation(KvMapping.class);
if(mapping == null) {
continue;
}
JavaType javaType;
String typeStr = mapping.type();
if(!typeStr.isEmpty()) {
javaType = tf.constructFromCanonical(typeStr);
} else {
javaType = tf.constructType(field.getGenericType());
}
KvProperty property = new KvProperty(this, field.getName(), field, javaType);
b.put(property.getKey(), func.apply(property));
}
clazz = clazz.getSuperclass();
}
return b.build();
}
示例2: typeFromId
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
JavaType typeFromId(String id, TypeFactory typeFactory) throws IllegalStateException {
String className = basePackage + "." + generateClassName(id);
try {
return typeFactory.constructType(typeFactory.findClass(className));
} catch (ClassNotFoundException ex) {
throw new IllegalStateException("Could not find event class for type " + id, ex);
}
}
示例3: makeDeserialiser
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
private BiFunction<JsonNode, Type, Object> makeDeserialiser(ObjectMapper mapper) {
final TypeFactory typeFactory = mapper.getTypeFactory();
return (node, type) -> {
JavaType javaType = typeFactory.constructType(type);
try {
final JsonParser jsonParser = mapper.treeAsTokens(node);
final ObjectCodec codec = jsonParser.getCodec();
return codec.readValue(jsonParser, javaType);
} catch (IOException e) {
throw new RuntimeException(e);
}
};
}
示例4: deserialize
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public Object deserialize(JsonParser p, DeserializationContext ctx) throws IOException {
if(jobsManager == null) {
throw new IllegalStateException("This deserializer need a jobsManager instance, see 'JobParametersDeserializer.setJobsManager'");
}
final JsonStreamContext jsc = p.getParsingContext();
String paramName = null;
JsonStreamContext parent = jsc;
while(parent != null) {
paramName = parent.getCurrentName();
if(paramName != null) {
break;
}
parent = parent.getParent();
}
if(parent == null) {
throw new NullPointerException("Something wrong: we can not find our parent object, " +
"may be you use this deserializer on custom object?");
}
JobParameters.Builder r = (JobParameters.Builder) parent.getParent().getCurrentValue();
String jobType = r.getType();
JobDescription desc = jobsManager.getDescription(jobType);
JobParameterDescription param = desc.getParameters().get(paramName);
TypeFactory typeFactory = ctx.getTypeFactory();
JavaType type;
if(param == null) {
type = typeFactory.constructType(Object.class);
} else {
type = typeFactory.constructType(param.getType());
}
JsonDeserializer<Object> deser = ctx.findNonContextualValueDeserializer(type);
try {
return deser.deserialize(p, ctx);
} catch (Exception e) {
throw new RuntimeException("Can not deserialize '" + jobType + "." + paramName + "' job parameter ", e );
}
}
示例5: getOutputType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(final TypeFactory typeFactory) {
return typeFactory.constructType(OAuthToken.class);
}
示例6: getOutputType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(TypeFactory typeFactory) {
return typeFactory.constructType(Date.class);
}
示例7: getInputType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getInputType(TypeFactory typeFactory) {
return typeFactory.constructType(String.class);
}
示例8: getInputType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getInputType(TypeFactory typeFactory) {
return typeFactory.constructType(Object.class);
}
示例9: getOutputType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(TypeFactory typeFactory) {
return typeFactory.constructType(Point3f.class); }
示例10: getInputType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getInputType(TypeFactory typeFactory) {
return typeFactory.constructType(Capability.class);
}
示例11: getOutputType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(TypeFactory typeFactory) {
return typeFactory.constructType(String.class);
}
示例12: getOutputType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(TypeFactory typeFactory) {
return typeFactory.constructType(String.class);
}
示例13: getInputType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getInputType(TypeFactory typeFactory) {
return typeFactory.constructType(Enum.class);
}
示例14: getOutputType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(TypeFactory typeFactory) {
return typeFactory.constructType(Long.class);
}
示例15: getJavaType
import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
/**
* Return the Jackson {@link JavaType} for the specified type and context class.
* <p>The default implementation returns {@code typeFactory.constructType(type, contextClass)},
* but this can be overridden in subclasses, to allow for custom generic collection handling.
* For instance:
* <pre class="code">
* protected JavaType getJavaType(Type type) {
* if (type instanceof Class && List.class.isAssignableFrom((Class)type)) {
* return TypeFactory.collectionType(ArrayList.class, MyBean.class);
* } else {
* return super.getJavaType(type);
* }
* }
* </pre>
* @param type the generic type to return the Jackson JavaType for
* @param contextClass a context class for the target type, for example a class
* in which the target type appears in a method signature (can be {@code null})
* @return the Jackson JavaType
*/
protected JavaType getJavaType(Type type, Class<?> contextClass) {
TypeFactory tf = this.objectMapper.getTypeFactory();
// Conditional call because Jackson 2.7 does not support null contextClass anymore
// TypeVariable resolution will not work with Jackson 2.7, see SPR-13853 for more details
return (contextClass != null ? tf.constructType(type, contextClass) : tf.constructType(type));
}
开发者ID:JetBrains,项目名称:teamcity-hashicorp-vault-plugin,代码行数:26,代码来源:AbstractJackson2HttpMessageConverter.java