PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/v3.2/nimbits-sdk/src/com/nimbits/gson/GsonFactory.java

http://nimbits-server.googlecode.com/
Java | 54 lines | 30 code | 6 blank | 18 comment | 2 complexity | 10e5f72f707f9e68cde2fd6c80476949 MD5 | raw file
 1/*
 2 * Copyright (c) 2010 Tonic Solutions LLC.
 3 *
 4 * http://www.nimbits.com
 5 *
 6 *
 7 * Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
 8 *
 9 * http://www.gnu.org/licenses/gpl.html
10 *
11 * Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
12 */
13
14package com.nimbits.gson;
15
16import com.google.gson.Gson;
17import com.google.gson.GsonBuilder;
18import com.google.gson.reflect.*;
19import com.nimbits.client.model.Const;
20import com.nimbits.client.model.category.impl.*;
21import com.nimbits.client.model.diagram.*;
22import com.nimbits.client.model.point.*;
23import com.nimbits.client.model.user.*;
24import com.nimbits.client.model.value.*;
25
26import java.lang.reflect.*;
27import java.util.*;
28
29/**
30 * Created by bsautner
31 * User: benjamin
32 * Date: 8/3/11
33 * Time: 8:39 PM
34 */
35public class GsonFactory {
36    private static Gson instance;
37    public final static Type categoryListType = new TypeToken<List<PointCategoryModelImpl>>() {}.getType();
38    public final static Type pointListType = new TypeToken<List<PointModel>>() {}.getType();
39    public final static Type diagramListType = new TypeToken<List<DiagramModel>>() {}.getType();
40    public final static Type userListType = new TypeToken<List<UserModel>>() {}.getType();
41    public final static Type valueListType = new TypeToken<List<ValueModel>>() {}.getType();
42       private GsonFactory() {
43            throw new AssertionError();
44       }
45
46       public static Gson getInstance() {
47           if (instance == null)
48           {
49                instance = new GsonBuilder().setDateFormat(Const.GSON_DATE_FORMAT).serializeNulls().create();
50           }
51           return instance;
52       }
53
54}