Skip to content
Snippets Groups Projects
Commit 4e3adf24 authored by Krzysztof Witukiewicz's avatar Krzysztof Witukiewicz
Browse files

OZG-3936 OZG-7793 Small changes after CR

parent f2c8c2f8
No related branches found
No related tags found
1 merge request!16Ozg 3936 refactor user profile url provider
......@@ -50,11 +50,17 @@ public class LinkedUserProfileResourceSerializer extends JsonSerializer<Object>
private final UserManagerUrlProvider userManagerUrlProvider;
private LinkedUserProfileResource annotation;
// for usage outside of Spring
// ObjectMapper uses this, if called outside of Spring, so dependency injection does not work
private LinkedUserProfileResourceSerializer() {
this(new UserManagerUrlProvider(new UserManagerProperties()));
}
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) {
return LinkedUserProfileResourceSerializer.createForAnnotatedField(userManagerUrlProvider,
property.getAnnotation(LinkedUserProfileResource.class));
}
static LinkedUserProfileResourceSerializer createForAnnotatedField(UserManagerUrlProvider userManagerUrlProvider,
LinkedUserProfileResource annotation) {
var serializer = new LinkedUserProfileResourceSerializer(userManagerUrlProvider);
......@@ -62,12 +68,6 @@ public class LinkedUserProfileResourceSerializer extends JsonSerializer<Object>
return serializer;
}
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) {
return LinkedUserProfileResourceSerializer.createForAnnotatedField(userManagerUrlProvider,
property.getAnnotation(LinkedUserProfileResource.class));
}
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
if (value instanceof Collection) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment