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 Details

    • RoleSerializer

      public RoleSerializer()
  • Method Details

    • serialize

      public com.google.gson.JsonElement serialize(Role src, Type typeOfSrc, com.google.gson.JsonSerializationContext context)
      Serializes a Role enum instance into a JSON element.
      Specified by:
      serialize in interface com.google.gson.JsonSerializer<Role>
      Parameters:
      src - the Role instance to serialize.
      typeOfSrc - the type of the source object.
      context - the serialization context.
      Returns:
      a JsonPrimitive containing the string value of the role.