04a — Core
Loading Bindings
A BindingLoader provides a convenient way to bulk-load bindings into a Bindings container from external sources such as Maps, POJOs, or other data structures. Instead of binding values one at a time, you can populate an entire set of bindings in a single call.
BindingLoader Interface
The BindingLoader is a functional interface that loads bindings into a given container:
@FunctionalInterface
public interface BindingLoader {
void load(Bindings bindings);
}
Loading from a Map
Use MapBindingLoader to load bindings from a Map<String, Object>:
Map<String, Object> data = new HashMap<>();
data.put("name", "Alice");
data.put("age", 30);
Bindings bindings = Bindings.builder().standard();
// Load the Map entries to the Bindings
bindings.load(new MapBindingLoader(), data);
Loading from a POJO
Use ObjectBindingLoader to load bindings from a Java object’s properties:
public class Customer {
private String name;
private int age;
// getters and setters
}
Customer customer = new Customer("Alice", 30);
Bindings bindings = Bindings.builder().standard();
bindings.load(new FieldBindingLoader(), customer);
// Each field becomes a binding: "name" -> "Alice", "age" -> 30
bindings.load(new PropertyBindingLoader(), customer);
// Each getter becomes a binding: "name" -> "Alice", "age" -> 30
Tip: When loading from a POJO, each readable property (getter) becomes a binding. The property name is used as the binding name and the property type is preserved.