Interface Binder
- All Known Implementing Classes:
DefaultBinder
public interface Binder
Binds config nodes to Java objects.
Supports both field injection and constructor binding.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceBuilder for creating customized Binder instances. -
Method Summary
Modifier and TypeMethodDescription<T> @NotNull BindingResult<T>bind(@NotNull ConfigNode node, @NotNull Class<T> type, @NotNull NamingStrategy namingStrategy) Binds a config node to a new instance of the target type.<T> @NotNull BindingResult<T>bind(@NotNull ConfigNode node, T instance, @NotNull NamingStrategy namingStrategy) Binds config values onto an existing instance (field injection only).static @NotNull Binder.Builderbuilder()Creates a binder builder with custom options.static @NotNull Bindercreate()Creates a default binder.<T> voidunbind(T object, @NotNull MutableConfigNode node, @NotNull NamingStrategy namingStrategy) Serializes an object to a config node.
-
Method Details
-
bind
@NotNull <T> @NotNull BindingResult<T> bind(@NotNull @NotNull ConfigNode node, @NotNull @NotNull Class<T> type, @NotNull @NotNull NamingStrategy namingStrategy) Binds a config node to a new instance of the target type.- Type Parameters:
T- the type parameter- Parameters:
node- the source nodetype- the target typenamingStrategy- the naming strategy for field to config key conversion- Returns:
- the binding result
-
bind
@NotNull <T> @NotNull BindingResult<T> bind(@NotNull @NotNull ConfigNode node, @NotNull T instance, @NotNull @NotNull NamingStrategy namingStrategy) Binds config values onto an existing instance (field injection only).- Type Parameters:
T- the type parameter- Parameters:
node- the source nodeinstance- the target instancenamingStrategy- the naming strategy for field to config key conversion- Returns:
- the binding result
-
unbind
<T> void unbind(@NotNull T object, @NotNull @NotNull MutableConfigNode node, @NotNull @NotNull NamingStrategy namingStrategy) Serializes an object to a config node.- Type Parameters:
T- the type parameter- Parameters:
object- the object to serializenode- the target nodenamingStrategy- the naming strategy for field to config key conversion
-
builder
Creates a binder builder with custom options.- Returns:
- a new builder
-
create
Creates a default binder.- Returns:
- a new binder
-