org.jsonex.jsoncoder.BeanCoderContext Maven / Gradle / Ivy
/*************************************************************
Copyright 2018-2019 eBay Inc.
Author/Developer: Jianwu Chen
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
************************************************************/
package org.jsonex.jsoncoder;
import org.jsonex.core.factory.CacheThreadLocal;
import org.jsonex.core.factory.InjectableFactory;
import org.jsonex.treedoc.TDNode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.LinkedList;
import java.util.Map;
import static org.jsonex.core.factory.InjectableFactory.of;
/**
* Context object for BeanCoder, it will save session information during encoding and provide a
* way to let client to customize the encode behavior.
*/
@RequiredArgsConstructor
public class BeanCoderContext {
// For performance reason, we need to cache SimpleDateFormat in the same thread as SimpleDateFormat is not threadsafe
public static final InjectableFactory dateFormatCache = of(SimpleDateFormat::new, CacheThreadLocal.get());
private int nextId = 1; // The next id for $ref
@Getter final JSONCoderOption option;
/**
* Used only for encoding, remember encoded objects to be used to dedupWithreference
* Key is the Object to be encoded or EqualsWrapper or the object, the value of this map is the converted result
*/
@Getter final Map