Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.ser.impl;
 
 
 
Simple value container used to keep track of Object Ids during serialization.
public final class WritableObjectId
    public final ObjectIdGenerator<?> generator;
    public Object id;
    protected boolean idWritten = false;
    
    public WritableObjectId(ObjectIdGenerator<?> generator) {
        this. = generator;
    }
    
    public boolean writeAsId(JsonGenerator jgenSerializerProvider providerObjectIdWriter w)
        throws IOExceptionJsonGenerationException
    {
        if ( != null && ( || w.alwaysAsId)) {
            // 03-Aug-2013, tatu: Prefer Native Object Ids if available
            if (jgen.canWriteObjectId()) {
                jgen.writeObjectRef(String.valueOf());
            } else {
                w.serializer.serialize(jgenprovider);
            }
            return true;
        }
        return false;
    }
    
    public Object generateId(Object forPojo) {
        return ( = .generateId(forPojo));
    }

    
Method called to output Object Id as specified.
    public void writeAsField(JsonGenerator jgenSerializerProvider provider,
            ObjectIdWriter w)
        throws IOExceptionJsonGenerationException
    {
         = true;
        // 03-Aug-2013, tatu: Prefer Native Object Ids if available
        if (jgen.canWriteObjectId()) {
            // Need to assume String(ified) ids, for now... could add 'long' variant?
            jgen.writeObjectId(String.valueOf());
            return;
        }
        
        SerializedString name = w.propertyName;
        if (name != null) {
            jgen.writeFieldName(name);
            w.serializer.serialize(jgenprovider);
        }
    }
New to GrepCode? Check out our FAQ X