Example usage for com.fasterxml.jackson.core JsonGenerator getClass

List of usage examples for com.fasterxml.jackson.core JsonGenerator getClass

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonGenerator getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.mongojack.internal.EmbeddedObjectSerializer.java

protected void writeEmbeddedObject(T value, JsonGenerator jgen) throws IOException {
    if (jgen instanceof BsonObjectGenerator || jgen instanceof DBEncoderBsonGenerator) {
        jgen.writeObject(value);//from  w w w. j ava2 s .  c o m
    } else if (jgen instanceof TokenBuffer) {
        TokenBuffer buffer = (TokenBuffer) jgen;
        ObjectCodec codec = buffer.getCodec();
        buffer.setCodec(null);
        buffer.writeObject(value);
        buffer.setCodec(codec);
    } else {
        String message = "JsonGenerator of type " + jgen.getClass().getName() + " not supported: "
                + getClass().getName() + " is designed for use only with " + BsonObjectGenerator.class.getName()
                + " or " + DBEncoderBsonGenerator.class.getName() + " or " + TokenBuffer.class.getName();
        throw new IllegalArgumentException(message);
    }
}