com.vaadin.addon.charts.model.gsonhelpers.ChartEnumSerializer.java Source code

Java tutorial

Introduction

Here is the source code for com.vaadin.addon.charts.model.gsonhelpers.ChartEnumSerializer.java

Source

package com.vaadin.addon.charts.model.gsonhelpers;

/*
 * #%L
 * Vaadin Charts
 * %%
 * Copyright (C) 2012 Vaadin Ltd
 * %%
 * This program is available under Commercial Vaadin Add-On License 2.0
 * (CVALv2).
 * 
 * See the file licensing.txt distributed with this software for more
 * information about licensing.
 * 
 * You should have received a copy of the CVALv2 along with this program.
 * If not, see <http://vaadin.com/license/cval-2.0>.
 * #L%
 */

import java.lang.reflect.Type;

import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.vaadin.addon.charts.model.ChartEnum;

/**
 * Serializer for enums
 */
public class ChartEnumSerializer implements JsonSerializer<ChartEnum> {

    @Override
    public JsonElement serialize(ChartEnum src, Type typeOfSrc, JsonSerializationContext context) {
        return new JsonPrimitive(src.toString());
    }

}