private static Optional<Constructor<?>> getConstructorHavingJsonBuilder(Class<?> clazz) { for (Constructor<?> constructor : clazz.getDeclaredConstructors()) { final List<Class<?>> parameterTypes = Arrays.stream(constructor.getParameterTypes()) .filter(s -> s.getName().contains("Builder")).collect(Collectors.toList()); if (parameterTypes.size() > 0) { final Annotation[] annotations = parameterTypes.get(0).getAnnotations(); for (Annotation annotation : annotations) { if (annotation.annotationType() == JsonPOJOBuilder.class) { return Optional.of(constructor); } } } } return Optional.empty(); }
protected POJOPropertiesCollector collectPropertiesWithBuilder(MapperConfig<?> config, JavaType type, MixInResolver r, boolean forSerialization) { boolean useAnnotations = config.isAnnotationProcessingEnabled(); AnnotationIntrospector ai = useAnnotations ? config.getAnnotationIntrospector() : null; AnnotatedClass ac; if (forSerialization) { ac = annotatedClassConstructor.constructForSerialization(type.getRawClass(), ai, r); } else { ac = annotatedClassConstructor.constructForDeserialization(type.getRawClass(), ai, r); } JsonPOJOBuilder.Value builderConfig = (ai == null) ? null : ai.findPOJOBuilderConfig(ac); String mutatorPrefix = (builderConfig == null) ? "with" : builderConfig.withPrefix; return constructPropertyCollector(config, ac, type, forSerialization, mutatorPrefix).collect(); }
public JsonPOJOBuilder.Value findPOJOBuilderConfig(AnnotatedClass paramAnnotatedClass) { JsonPOJOBuilder localJsonPOJOBuilder = (JsonPOJOBuilder)paramAnnotatedClass.getAnnotation(JsonPOJOBuilder.class); if (localJsonPOJOBuilder == null) return null; return new JsonPOJOBuilder.Value(localJsonPOJOBuilder); }
@Override public JsonPOJOBuilder.Value findPOJOBuilderConfig(AnnotatedClass ac) { JsonPOJOBuilder.Value result = _primary.findPOJOBuilderConfig(ac); if (result == null) { result = _secondary.findPOJOBuilderConfig(ac); } return result; }
protected POJOPropertiesCollector collectPropertiesWithBuilder(MapperConfig<?> config, JavaType type, MixInResolver r, boolean forSerialization) { boolean useAnnotations = config.isAnnotationProcessingEnabled(); AnnotationIntrospector ai = useAnnotations ? config.getAnnotationIntrospector() : null; AnnotatedClass ac = AnnotatedClass.construct(type.getRawClass(), ai, r); JsonPOJOBuilder.Value builderConfig = (ai == null) ? null : ai.findPOJOBuilderConfig(ac); String mutatorPrefix = (builderConfig == null) ? "with" : builderConfig.withPrefix; return constructPropertyCollector(config, ac, type, forSerialization, mutatorPrefix).collect(); }
@Override public JsonPOJOBuilder.Value findPOJOBuilderConfig() { return (_annotationIntrospector == null) ? null : _annotationIntrospector.findPOJOBuilderConfig(_classInfo); }
public void setPOJOBuilder(AnnotatedMethod buildMethod, JsonPOJOBuilder.Value config) { _buildMethod = buildMethod; _builderConfig = config; }
public JsonPOJOBuilder.Value getBuilderConfig() { return _builderConfig; }
/** * @since 2.0 */ public JsonPOJOBuilder.Value findPOJOBuilderConfig(AnnotatedClass ac) { return null; }
/** * Method for finding configuration for POJO Builder class. */ public abstract JsonPOJOBuilder.Value findPOJOBuilderConfig();