Class Role.RoleSerializer
java.lang.Object
com.developer.nefarious.zjoule.plugin.models.Role.RoleSerializer
- All Implemented Interfaces:
com.google.gson.JsonSerializer<Role>
- Enclosing class:
Role
public static class Role.RoleSerializer
extends Object
implements com.google.gson.JsonSerializer<Role>
Custom serializer for the
Role
enum to be used with Gson.
Converts a Role
enum instance into its corresponding JSON representation,
which is the string value of the role.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
RoleSerializer
public RoleSerializer()
-
-
Method Details
-
serialize
public com.google.gson.JsonElement serialize(Role src, Type typeOfSrc, com.google.gson.JsonSerializationContext context) Serializes aRole
enum instance into a JSON element.- Specified by:
serialize
in interfacecom.google.gson.JsonSerializer<Role>
- Parameters:
src
- theRole
instance to serialize.typeOfSrc
- the type of the source object.context
- the serialization context.- Returns:
- a
JsonPrimitive
containing the string value of the role.
-