当前位置: 首页>>代码示例>>Java>>正文


Java TypeFactory.constructType方法代码示例

本文整理汇总了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();
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:24,代码来源:KvMapperFactory.java

示例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);
    }
}
 
开发者ID:goodees,项目名称:goodees,代码行数:9,代码来源:ImmutableEventTypeResolver.java

示例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);
        }
    };
}
 
开发者ID:opencredo,项目名称:concursus,代码行数:15,代码来源:EventJson.java

示例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 );
    }
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:38,代码来源:JobParametersDeserializer.java

示例5: getOutputType

import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(final TypeFactory typeFactory) {
    return typeFactory.constructType(OAuthToken.class);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:5,代码来源:OAuth1CredentialFlowState.java

示例6: getOutputType

import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(TypeFactory typeFactory) {
    return typeFactory.constructType(Date.class);
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:5,代码来源:WxJsonAdapters.java

示例7: getInputType

import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getInputType(TypeFactory typeFactory) {
    return typeFactory.constructType(String.class);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:5,代码来源:KvSupportModule.java

示例8: getInputType

import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getInputType(TypeFactory typeFactory) {
    return typeFactory.constructType(Object.class);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:5,代码来源:StringConverter.java

示例9: getOutputType

import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(TypeFactory typeFactory) {
    return typeFactory.constructType(Point3f.class);    }
 
开发者ID:ZoltanTheHun,项目名称:SkyHussars,代码行数:4,代码来源:Vector3fToPoint3fConverter.java

示例10: getInputType

import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getInputType(TypeFactory typeFactory) {
	return typeFactory.constructType(Capability.class);
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:5,代码来源:Policy.java

示例11: getOutputType

import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(TypeFactory typeFactory) {
	return typeFactory.constructType(String.class);
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:5,代码来源:Policy.java

示例12: getOutputType

import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(TypeFactory typeFactory) {
    return typeFactory.constructType(String.class);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:5,代码来源:KvSupportModule.java

示例13: getInputType

import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getInputType(TypeFactory typeFactory) {
    return typeFactory.constructType(Enum.class);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:5,代码来源:EnumToLowercaseStringConverter.java

示例14: getOutputType

import com.fasterxml.jackson.databind.type.TypeFactory; //导入方法依赖的package包/类
@Override
public JavaType getOutputType(TypeFactory typeFactory) {
    return typeFactory.constructType(Long.class);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:5,代码来源:MemoryFromStringConverter.java

示例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


注:本文中的com.fasterxml.jackson.databind.type.TypeFactory.constructType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。