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

com.axway.apim.adapter.jackson.OrganizationSerializer Maven / Gradle / Ivy

package com.axway.apim.adapter.jackson;

import java.io.IOException;

import com.axway.apim.api.model.Organization;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

public class OrganizationSerializer extends StdSerializer {
	
	private static final long serialVersionUID = 1L;
	
	boolean serializeAsName = true;
	
	public OrganizationSerializer() {
		this(null);
	}
	
	public OrganizationSerializer(boolean serializeAsName) {
		this(null);
		this.serializeAsName = serializeAsName;
	}

	public OrganizationSerializer(Class organization) {
		super(organization);
	}

	@Override
	public void serialize(Organization organization, JsonGenerator jgen, SerializerProvider provider) throws IOException {
		if(serializeAsName) {
			jgen.writeString(organization.getName());
		} else {
			jgen.writeString(organization.getId());
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy