Example usage for com.fasterxml.jackson.databind SerializerProvider findObjectId

List of usage examples for com.fasterxml.jackson.databind SerializerProvider findObjectId


In this page you can find the example usage for com.fasterxml.jackson.databind SerializerProvider findObjectId.


public abstract WritableObjectId findObjectId(Object paramObject, ObjectIdGenerator<?> paramObjectIdGenerator);

Source Link


From source file:com.github.shyiko.jackson.module.advice.AdvisedBeanSerializer.java

protected void serializeWithObjectId(Object bean, JsonGenerator jgen, SerializerProvider provider,
        boolean startEndObject) throws IOException {
    final ObjectIdWriter w = _objectIdWriter;
    WritableObjectId objectId = provider.findObjectId(bean, w.generator);
    // If possible, write as id already
    if (objectId.writeAsId(jgen, provider, w)) {
        return;//  w  ww.  ja  v  a  2 s . c o  m
    // If not, need to inject the id:
    Object id = objectId.generateId(bean);
    if (w.alwaysAsId) {
        w.serializer.serialize(id, jgen, provider);
    if (startEndObject) {
    if (!beanSerializerAdvice.intercept(bean, jgen, provider)) {
        beanSerializerAdvice.before(bean, jgen, provider);
        objectId.writeAsField(jgen, provider, w);
        if (_propertyFilterId != null) {
            serializeFieldsFiltered(bean, jgen, provider);
        } else {
            serializeFields(bean, jgen, provider);
        beanSerializerAdvice.after(bean, jgen, provider);
    if (startEndObject) {