Class JsonMetadataSerializer

  • All Implemented Interfaces:
    com.google.gson.JsonSerializer<Metadata>

    public class JsonMetadataSerializer
    extends Object
    implements com.google.gson.JsonSerializer<Metadata>
    Serializer for Metadata If overriding this, remember that this is called from a static context. Share state only with great caution.
    • Constructor Detail

      • JsonMetadataSerializer

        public JsonMetadataSerializer()
    • Method Detail

      • serialize

        public com.google.gson.JsonElement serialize​(Metadata metadata,
                                                     Type type,
                                                     com.google.gson.JsonSerializationContext context)
        Serializes a Metadata object into effectively Map.
        Specified by:
        serialize in interface com.google.gson.JsonSerializer<Metadata>
        Parameters:
        metadata - object to serialize
        type - (ignored)
        context - (ignored)
        Returns:
        JsonElement with key/value(s) pairs or JsonNull if metadata is null.
      • getNames

        protected String[] getNames​(Metadata metadata)
        Override to get a custom sort order or to filter names.
        Parameters:
        metadata - metadata from which to grab names
        Returns:
        list of names in the order in which they should be serialized