Object LoadOptionsJson

  • All Implemented Interfaces:

    
    public class LoadOptionsJson
    
                        

    Provides JSON serialization and deserialization support for LoadOptions.

    This class enables converting LoadOptions to/from JSON format, which is useful for:

    • REST API payloads

    • Configuration files

    • Debugging and logging

    Example usage:

    // Convert to JSON
    val options = LoadOptions.parse("-expires 1d -ignoreFailure")
    val json = LoadOptionsJson.toJson(options)
    
    // Convert from JSON
    val options2 = LoadOptionsJson.fromJson(json)
    
    // Get a JSON template with all fields and their default values
    val template = LoadOptionsJson.generateJsonTemplate()
    • Constructor Detail

    • Method Detail

      • toJson

        @JvmOverloads() final static String toJson(LoadOptions options, Boolean includeDefaults)

        Converts a LoadOptions instance to a JSON string.

        Only includes fields that differ from their default values to keep the output concise.

        Parameters:
        options - the LoadOptions to serialize
        includeDefaults - if true, includes all fields; if false, only non-default values
        Returns:

        JSON string representation

      • toJson

        @JvmOverloads() final static String toJson(LoadOptions options)

        Converts a LoadOptions instance to a JSON string.

        Only includes fields that differ from their default values to keep the output concise.

        Parameters:
        options - the LoadOptions to serialize
        Returns:

        JSON string representation

      • toPrettyJson

        @JvmOverloads() final static String toPrettyJson(LoadOptions options, Boolean includeDefaults)

        Converts a LoadOptions instance to a JSON string with pretty printing.

        Parameters:
        options - the LoadOptions to serialize
        includeDefaults - if true, includes all fields; if false, only non-default values
        Returns:

        formatted JSON string representation

      • toPrettyJson

        @JvmOverloads() final static String toPrettyJson(LoadOptions options)

        Converts a LoadOptions instance to a JSON string with pretty printing.

        Parameters:
        options - the LoadOptions to serialize
        Returns:

        formatted JSON string representation

      • fromJson

        @JvmOverloads() final static LoadOptions fromJson(String json, VolatileConfig conf)

        Creates a LoadOptions instance from a JSON string.

        Parameters:
        json - the JSON string to parse
        conf - the VolatileConfig to use for the created LoadOptions
        Returns:

        a new LoadOptions instance with values from the JSON

      • fromJson

        @JvmOverloads() final static LoadOptions fromJson(String json)

        Creates a LoadOptions instance from a JSON string.

        Parameters:
        json - the JSON string to parse
        Returns:

        a new LoadOptions instance with values from the JSON

      • fromMap

        @JvmOverloads() final static LoadOptions fromMap(Map<String, Object> map, VolatileConfig conf)

        Converts a map of options to a LoadOptions instance.

        Parameters:
        map - the map containing option names and values
        conf - the VolatileConfig to use for the created LoadOptions
        Returns:

        a new LoadOptions instance

      • fromMap

        @JvmOverloads() final static LoadOptions fromMap(Map<String, Object> map)

        Converts a map of options to a LoadOptions instance.

        Parameters:
        map - the map containing option names and values
        Returns:

        a new LoadOptions instance

      • toMap

         final static Map<String, Object> toMap(LoadOptions options)

        Converts a LoadOptions instance to a map of all option values.

        Parameters:
        options - the LoadOptions to convert
        Returns:

        a map of field names to their values

      • toModifiedMap

         final static Map<String, Object> toModifiedMap(LoadOptions options)

        Converts a LoadOptions instance to a map of only modified (non-default) values.

        Parameters:
        options - the LoadOptions to convert
        Returns:

        a map of field names to their modified values

      • generateJsonTemplate

         final static String generateJsonTemplate()

        Generates a JSON template showing all LoadOptions fields with their default values.

        This is useful for documentation and as a starting point for configuration files.

        Returns:

        a formatted JSON string containing all fields and their default values

      • generateJsonTemplateWithDescriptions

         final static String generateJsonTemplateWithDescriptions()

        Generates a JSON template with descriptions for each field.

        Returns:

        a formatted JSON string with field descriptions as comments