package com.changhu.support.fastjson2.serializer;

import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.writer.ObjectWriter;
import org.geotools.measure.Latitude;

import java.lang.reflect.Type;

/**
 * author: luozhun
 * desc: LatitudeSerializer
 * createTime: 2023/8/26 15:44
 */
public class LatitudeSerializer implements ObjectWriter<Latitude> {

    public static final LatitudeSerializer instance = new LatitudeSerializer();

    private LatitudeSerializer() {
    }

    @Override
    public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) {
        if (object == null) {
            jsonWriter.writeNull();
            return;
        }
        jsonWriter.writeDouble(((Latitude) object).degrees());
    }
}

