All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.redkale.convert.bson.BsonFactory Maven / Gradle / Ivy

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.redkale.convert.bson;

import java.io.Serializable;
import org.redkale.convert.*;
import org.redkale.util.AnyValue;

/**
 * BSON的ConvertFactory
 *
 * 

* 详情见: https://redkale.org * * @author zhangjx */ @SuppressWarnings("unchecked") public final class BsonFactory extends ConvertFactory { private static final BsonFactory instance = new BsonFactory(null, Boolean.getBoolean("convert.bson.tiny")); static final Decodeable objectDecoder = instance.loadDecoder(Object.class); static final Encodeable objectEncoder = instance.loadEncoder(Object.class); static { instance.register(Serializable.class, objectDecoder); instance.register(Serializable.class, objectEncoder); instance.register(AnyValue.class, instance.loadDecoder(AnyValue.DefaultAnyValue.class)); instance.register(AnyValue.class, instance.loadEncoder(AnyValue.DefaultAnyValue.class)); } private BsonFactory(BsonFactory parent, boolean tiny) { super(parent, tiny); } @Override public BsonFactory tiny(boolean tiny) { this.tiny = tiny; return this; } @Override public BsonFactory skipAllIgnore(final boolean skipIgnore) { this.registerSkipAllIgnore(skipIgnore); return this; } public static BsonFactory root() { return instance; } public static BsonFactory create() { return new BsonFactory(null, Boolean.getBoolean("convert.bson.tiny")); } @Override public final BsonConvert getConvert() { if (convert == null) convert = new BsonConvert(this, tiny); return (BsonConvert) convert; } @Override public BsonFactory createChild() { return new BsonFactory(this, this.tiny); } @Override public BsonFactory createChild(boolean tiny) { return new BsonFactory(this, tiny); } @Override public ConvertType getConvertType() { return ConvertType.BSON; } @Override public boolean isReversible() { return true; } @Override public boolean isFieldSort() { return true; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy