Package com.tnsai.output
Enum Class OutputFormat
- All Implemented Interfaces:
Serializable,Comparable<OutputFormat>,Constable
Supported output formats for structured agent responses.
Each format has different trade-offs between human readability,
token efficiency, and data structure support.
Token efficiency comparison (approximate):
- JSON: Baseline (universal, verbose)
- YAML: ~10-15% fewer tokens (human-readable, good for nested)
- TOON: ~40% fewer tokens (tabular arrays, uniform data)
- TONL: ~32-50% fewer tokens (schema-typed, large datasets)
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic OutputFormatfromString(String value) Parses a format from string (case-insensitive).Gets the file extension for this format.Gets the MIME type for this format.booleanReturns true if this format supports nested/hierarchical data.static OutputFormatReturns the enum constant of this class with the specified name.static OutputFormat[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
JSON
JSON (JavaScript Object Notation). Universal format, widely supported, verbose but reliable. Best for: API responses, complex nested structures, interoperability. -
YAML
YAML (YAML Ain't Markup Language). Human-readable, indentation-based, good for configuration. Best for: Spec files, human review, nested data. -
TOON
TOON (Token-Optimized Object Notation). Combines YAML-style nesting with CSV-style tabular arrays. Best for: Uniform arrays of objects, LLM token optimization.- See Also:
-
TONL
TONL (Token-Optimized Notation Language). Table-like format with schema support. Best for: Large datasets, typed data, maximum token savings.- See Also:
-
TEXT
Plain Text. Unstructured text output. Best for: Simple messages, creative writing, non-structured data.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getExtension
Gets the file extension for this format. -
getMimeType
Gets the MIME type for this format. -
supportsNesting
public boolean supportsNesting()Returns true if this format supports nested/hierarchical data. -
fromString
Parses a format from string (case-insensitive).- Parameters:
value- the format name- Returns:
- the OutputFormat
- Throws:
IllegalArgumentException- if format is unknown
-