com.atlan.serde.ClientAwareSerializerProvider Maven / Gradle / Ivy
/* SPDX-License-Identifier: Apache-2.0
Copyright 2023 Atlan Pte. Ltd. */
package com.atlan.serde;
import com.atlan.AtlanClient;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.cfg.CacheProvider;
import com.fasterxml.jackson.databind.cfg.HandlerInstantiator;
import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
import com.fasterxml.jackson.databind.ser.SerializerFactory;
import com.fasterxml.jackson.databind.util.ClassUtil;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
public class ClientAwareSerializerProvider extends DefaultSerializerProvider {
private static final long serialVersionUID = 2L;
private final AtlanClient client;
public ClientAwareSerializerProvider(AtlanClient client) {
super();
this.client = client;
}
public ClientAwareSerializerProvider(ClientAwareSerializerProvider src) {
super(src);
this.client = src.client;
}
protected ClientAwareSerializerProvider(
SerializerProvider src, SerializationConfig config, SerializerFactory f, AtlanClient client) {
super(src, config, f);
this.client = client;
}
@Override
public DefaultSerializerProvider withCaches(CacheProvider cacheProvider) {
return this;
}
@Override
public DefaultSerializerProvider createInstance(SerializationConfig config, SerializerFactory jsf) {
return new ClientAwareSerializerProvider(this, config, jsf, client);
}
@Override
public DefaultSerializerProvider copy() {
if (getClass() != ClientAwareSerializerProvider.class) {
return super.copy();
}
return new ClientAwareSerializerProvider(this);
}
@Override
public JsonSerializer