Interface KeyValues

All Superinterfaces:
Iterable<KeyValue>

public interface KeyValues extends Iterable<KeyValue>
Represents a collection of KeyValue entries with various utility methods for manipulation, transformation, and expansion. This interface serves as a central point for managing key-value pairs, allowing operations such as filtering, mapping, and interpolation.

KeyValues is basically a glorified Supplier<Stream<KeyValue>>. If the key values will be streamed multiple times it is recommended to call memoize() which will copy the key values if the key values are not already memoized.

Key Features:

Usage Example:

The following example demonstrates how to create, expand, and transform key-values:
// Create a builder and add key-value pairs
KeyValues.Builder builder = KeyValues.builder();
builder.add("key1", "value1");
builder.add("key2", "${key1}-${key3}");

// Build the KeyValues collection
KeyValues kvs = builder.build();

// Interpolate values using a Variables map
Variables variables = Variables.builder().add("key1", "interpolated").add("key3", "value3").build();

KeyValues expanded = kvs.expand(variables);

// Convert to a map
Map<String, String> map = expanded.toMap();
System.out.println(map); // {key1=value1, key2=value1-value3}
See Also: