Java Code Examples for com.fasterxml.jackson.databind.type.TypeFactory#constructType()
The following examples show how to use
com.fasterxml.jackson.databind.type.TypeFactory#constructType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldDocumentationGenerator.java From spring-auto-restdocs with Apache License 2.0 | 6 votes |
public FieldDescriptors generateDocumentation(Type baseType, TypeFactory typeFactory) throws JsonMappingException { JavaType javaBaseType = typeFactory.constructType(baseType); List<JavaType> types = resolveAllTypes(javaBaseType, typeFactory, typeMapping); FieldDescriptors result = new FieldDescriptors(); FieldDocumentationVisitorWrapper visitorWrapper = FieldDocumentationVisitorWrapper.create( javadocReader, constraintReader, deserializationConfig, new TypeRegistry(typeMapping, types), typeFactory, translationResolver, skipAccessor); for (JavaType type : types) { log.debug("(TOP) {}", type.getRawClass().getSimpleName()); if (RESOURCES_TYPES.contains(type.getRawClass().getCanonicalName())) { result.setNoContentMessageKey("body-as-embedded-resources"); continue; } writer.acceptJsonFormatVisitor(type, visitorWrapper); } for (FieldDescriptor descriptor : visitorWrapper.getFields()) { result.putIfAbsent(descriptor.getPath(), descriptor); } return result; }
Example 2
Source File: KvMapperFactory.java From haven-platform with Apache License 2.0 | 6 votes |
<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(); }
Example 3
Source File: PayloadTypeFactory.java From data-highway with Apache License 2.0 | 5 votes |
static PayloadTypeFactory fromClass(Class<?> payloadClass) { return new PayloadTypeFactory() { private static final long serialVersionUID = 1L; @Override public JavaType construct(TypeFactory typeFactory) { return typeFactory.constructType(payloadClass); } }; }
Example 4
Source File: ReflectionUtils.java From swagger-inflector with Apache License 2.0 | 5 votes |
public JavaType[] getOperationParameterClasses(Operation operation, String mediaType, Map<String, Schema> definitions) { TypeFactory tf = Json.mapper().getTypeFactory(); if (operation.getParameters() == null){ operation.setParameters(new ArrayList<>()); } int body = 0; JavaType[] bodyArgumentClasses = null; if (operation.getRequestBody() != null){ bodyArgumentClasses = getTypeFromRequestBody(operation.getRequestBody(), mediaType, definitions); if (bodyArgumentClasses != null) { body = bodyArgumentClasses.length; } } JavaType[] jt = new JavaType[operation.getParameters().size() + 1 + body]; int i = 0; jt[i] = tf.constructType(RequestContext.class); i += 1; for (Parameter parameter : operation.getParameters()) { JavaType argumentClasses = getTypeFromParameter(parameter, definitions); jt[i] = argumentClasses; i += 1; } if (operation.getRequestBody() != null && bodyArgumentClasses != null) { for (JavaType argument :bodyArgumentClasses) { jt[i] = argument; i += 1; } } return jt; }
Example 5
Source File: JsonUtils.java From carina with Apache License 2.0 | 5 votes |
public static <T> T fromJson(File file, Type type) { try { TypeFactory tf = mapper.getTypeFactory(); JavaType javaType = tf.constructType(type); return mapper.readValue(file, javaType); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
Example 6
Source File: ListJacksonJsonTypeDetector.java From camunda-external-task-client-java with Apache License 2.0 | 5 votes |
protected JavaType constructType(Object object) { TypeFactory typeFactory = TypeFactory.defaultInstance(); if (object instanceof List && !((List<?>) object).isEmpty()) { List<?> list = (List<?>) object; Object firstElement = list.get(0); if (bindingsArePresent(list.getClass())) { final JavaType elementType = constructType(firstElement); return typeFactory.constructCollectionType(list.getClass(), elementType); } } return typeFactory.constructType(object.getClass()); }
Example 7
Source File: WxJsonAdapters.java From FastBootWeixin with Apache License 2.0 | 4 votes |
@Override public JavaType getOutputType(TypeFactory typeFactory) { return typeFactory.constructType(Date.class); }
Example 8
Source File: MemoryFromStringConverter.java From haven-platform with Apache License 2.0 | 4 votes |
@Override public JavaType getInputType(TypeFactory typeFactory) { return typeFactory.constructType(String.class); }
Example 9
Source File: MemoryToStringConverter.java From haven-platform with Apache License 2.0 | 4 votes |
@Override public JavaType getInputType(TypeFactory typeFactory) { return typeFactory.constructType(Long.class); }
Example 10
Source File: Policy.java From spring-vault with Apache License 2.0 | 4 votes |
@Override public JavaType getOutputType(TypeFactory typeFactory) { return typeFactory.constructType(String.class); }
Example 11
Source File: Policy.java From spring-vault with Apache License 2.0 | 4 votes |
@Override public JavaType getOutputType(TypeFactory typeFactory) { return typeFactory.constructType(Capability.class); }
Example 12
Source File: OAuth2CredentialFlowState.java From syndesis with Apache License 2.0 | 4 votes |
@Override public JavaType getOutputType(final TypeFactory typeFactory) { return typeFactory.constructType(OAuthToken.class); }
Example 13
Source File: OAuth1CredentialFlowState.java From syndesis with Apache License 2.0 | 4 votes |
@Override public JavaType getOutputType(final TypeFactory typeFactory) { return typeFactory.constructType(OAuthToken.class); }
Example 14
Source File: JsonRequestMarshaller.java From ob1k with Apache License 2.0 | 4 votes |
private JavaType getJacksonType(final Type type) { final TypeFactory typeFactory = TypeFactory.defaultInstance(); return typeFactory.constructType(type); }
Example 15
Source File: KvSupportModule.java From haven-platform with Apache License 2.0 | 4 votes |
@Override public JavaType getOutputType(TypeFactory typeFactory) { return typeFactory.constructType(String.class); }
Example 16
Source File: ReflectionUtils.java From swagger-inflector with Apache License 2.0 | 4 votes |
public JavaType updateArgumentClass(Class<?> methodArg) { TypeFactory tf = Json.mapper().getTypeFactory(); return tf.constructType(methodArg); }
Example 17
Source File: Jackson2CodecSupport.java From java-technology-stack with MIT License | 4 votes |
protected JavaType getJavaType(Type type, @Nullable Class<?> contextClass) { TypeFactory typeFactory = this.objectMapper.getTypeFactory(); return typeFactory.constructType(GenericTypeResolver.resolveType(type, contextClass)); }
Example 18
Source File: StringConverter.java From haven-platform with Apache License 2.0 | 4 votes |
@Override public JavaType getInputType(TypeFactory typeFactory) { return typeFactory.constructType(Object.class); }
Example 19
Source File: AbstractJackson2HttpMessageConverter.java From java-technology-stack with MIT License | 2 votes |
/** * Return the Jackson {@link JavaType} for the specified type and context class. * @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, @Nullable Class<?> contextClass) { TypeFactory typeFactory = this.objectMapper.getTypeFactory(); return typeFactory.constructType(GenericTypeResolver.resolveType(type, contextClass)); }
Example 20
Source File: AbstractJackson2HttpMessageConverter.java From spring-analysis-note with MIT License | 2 votes |
/** * Return the Jackson {@link JavaType} for the specified type and context class. * @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, @Nullable Class<?> contextClass) { TypeFactory typeFactory = this.objectMapper.getTypeFactory(); return typeFactory.constructType(GenericTypeResolver.resolveType(type, contextClass)); }