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

com.microsoft.bingads.internal.restful.adaptor.EnumSerializer Maven / Gradle / Ivy

Go to download

The Bing Ads Java SDK is a library improving developer experience when working with the Bing Ads services by providing high-level access to features such as Bulk API, OAuth Authorization and SOAP API.

There is a newer version: 13.0.22.1
Show newest version
package com.microsoft.bingads.internal.restful.adaptor;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;


public class EnumSerializer extends StdSerializer> implements ContextualSerializer {
	private Class enumClass;

    public EnumSerializer() {
        super(Enum.class, false);
    }

    public EnumSerializer(Class enumClass) {
        super(enumClass, false);
        this.enumClass = enumClass;
    }

	@Override
	public void serialize(Enum value, JsonGenerator gen, SerializerProvider provider) throws IOException {
		gen.writeObject(AdaptorUtil.toCamelcase(value));
	}

	@Override
	public JsonSerializer createContextual(SerializerProvider prov, BeanProperty property)
			throws JsonMappingException {
		Class enumClass = property.getType().getRawClass();
        return new EnumSerializer(enumClass);
	}


    
	

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy