package com.changhu.support.fastjson2.serializer;

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

import java.lang.reflect.Type;

/**
 * author: luozhun
 * desc: LongitudeSerializer
 * createTime: 2023/8/26 15:46
 */
public class LongitudeSerializer implements ObjectWriter<Longitude> {

    public static final LongitudeSerializer instance = new LongitudeSerializer();

    private LongitudeSerializer() {
    }

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

