Object LoadOptionsJson
-
- All Implemented Interfaces:
public class LoadOptionsJsonProvides 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()
-
-
Field Summary
Fields Modifier and Type Field Description public final static LoadOptionsJsonINSTANCE
-
Method Summary
Modifier and Type Method Description final static StringtoJson(LoadOptions options, Boolean includeDefaults)Converts a LoadOptions instance to a JSON string. final static StringtoJson(LoadOptions options)Converts a LoadOptions instance to a JSON string. final static StringtoPrettyJson(LoadOptions options, Boolean includeDefaults)Converts a LoadOptions instance to a JSON string with pretty printing. final static StringtoPrettyJson(LoadOptions options)Converts a LoadOptions instance to a JSON string with pretty printing. final static LoadOptionsfromJson(String json, VolatileConfig conf)Creates a LoadOptions instance from a JSON string. final static LoadOptionsfromJson(String json)Creates a LoadOptions instance from a JSON string. final static LoadOptionsfromMap(Map<String, Object> map, VolatileConfig conf)Converts a map of options to a LoadOptions instance. final static LoadOptionsfromMap(Map<String, Object> map)Converts a map of options to a LoadOptions instance. final static Map<String, Object>toMap(LoadOptions options)Converts a LoadOptions instance to a map of all option values. final static Map<String, Object>toModifiedMap(LoadOptions options)Converts a LoadOptions instance to a map of only modified (non-default) values. final static StringgenerateJsonTemplate()Generates a JSON template showing all LoadOptions fields with their default values. final static StringgenerateJsonTemplateWithDescriptions()Generates a JSON template with descriptions for each field. -
-
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 serializeincludeDefaults- 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 serializeincludeDefaults- 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 parseconf- 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 valuesconf- 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
-
-
-
-