/**
 * Copyright 2008-2009. Chongqing CRun Information Industry Co.,Ltd. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.common.jackson;

import java.io.IOException;
import java.net.URI;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;

/**
 * @author 田平 create 2017年10月27日下午4:31:16
 */
public class URISerializer extends StdScalarSerializer<URI> {
	private static final long serialVersionUID = 1L;

	protected URISerializer(Class<URI> t) {
		super(t);
	}

	@Override
	public void serialize(URI value, JsonGenerator gen, SerializerProvider provider) throws IOException {
		if (value != null) {
			gen.writeString(value.toString());
		} else {
			gen.writeNull();
		}
	}

}
