com.geotab.model.serialization.UserAsStringSerializer Maven / Gradle / Ivy
package com.geotab.model.serialization;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.geotab.model.entity.user.User;
import java.io.IOException;
public class UserAsStringSerializer extends JsonSerializer {
@Override
public void serialize(User user, JsonGenerator jsonGenerator,
SerializerProvider serializerProvider) throws IOException {
if (user.isSystemEntity()) {
jsonGenerator.writeString(user.getId().getId());
} else {
jsonGenerator.writeObject(user.getId());
}
}
}