package it.integry.integrywmsnative.core.utility;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.lang.reflect.Modifier;
import java.time.LocalDate;
import java.time.LocalDateTime;

import it.integry.integrywmsnative.core.model.secondary.StatoPartitaMag;
import it.integry.integrywmsnative.core.rest.deserializer.LocalDateDeserializer;
import it.integry.integrywmsnative.core.rest.deserializer.LocalDateTimeDeserializer;
import it.integry.integrywmsnative.core.rest.deserializer.StatoPartitaMagDeserializer;
import it.integry.integrywmsnative.core.rest.serializer.LocalDateSerializer;
import it.integry.integrywmsnative.core.rest.serializer.LocalDateTimeSerializer;
import it.integry.integrywmsnative.core.rest.serializer.StatoPartitaMagSerializer;

public class UtilityGson {

    public static Gson createObject() {
        return new GsonBuilder()
                .setDateFormat("dd/MM/yyyy HH:mm:ss")
                .excludeFieldsWithModifiers(Modifier.TRANSIENT)
                .registerTypeAdapter(LocalDate.class, new LocalDateDeserializer())
                .registerTypeAdapter(LocalDate.class, new LocalDateSerializer())
                .registerTypeAdapter(LocalDateTime.class, new LocalDateTimeDeserializer())
                .registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer())
                .registerTypeAdapter(StatoPartitaMag.class, new StatoPartitaMagDeserializer())
                .registerTypeAdapter(StatoPartitaMag.class, new StatoPartitaMagSerializer())
                .create();
    }

}
