當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。