Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

public class Main {
    private static Gson gson = null;

    public static void init(HashMap<Type, Object> typeAdapterHashMap) {
        GsonBuilder gsonBuilder = new GsonBuilder();

        for (Map.Entry<Type, Object> entry : typeAdapterHashMap.entrySet()) {
            gsonBuilder.registerTypeAdapter(entry.getKey(), entry.getValue());
        }

        gson = gsonBuilder.create();
    }
}