All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.spincast.plugins.gson.serializers.ClassSerializer Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package org.spincast.plugins.gson.serializers;

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;

public class ClassSerializer implements JsonSerializer> {

    @Override
    public JsonElement serialize(Class clazz,
                                 Type typeOfSrc,
                                 JsonSerializationContext context) {
        if (clazz == null) {
            return null;
        }

        return new JsonPrimitive(clazz.getName());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy