Class JsonModule.SimpleModule
java.lang.Object
cloud.opencode.base.json.spi.JsonModule.SimpleModule
- All Implemented Interfaces:
JsonModule
- Enclosing interface:
JsonModule
Simple Module - Convenient Base Implementation of JsonModule
简单模块 - JsonModule 的便捷基础实现
Provides a convenient way to create modules by collecting
adapters, factories, and mixins before registering them via
setupModule(SetupContext).
提供一种便捷的方式来创建模块,在通过 setupModule(SetupContext)
注册之前收集适配器、工厂和混入。
Example | 示例:
SimpleModule module = new SimpleModule("custom", "1.0.0")
.addAdapter(new MoneyAdapter())
.addFactory(new EnumAdapterFactory())
.addMixin(User.class, UserMixin.class);
- Since:
- JDK 25, opencode-base-json V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Nested Class Summary
Nested classes/interfaces inherited from interface JsonModule
JsonModule.SetupContext, JsonModule.SimpleModule -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSimpleModule(String name, String version) Constructs a SimpleModule with the given name and version. -
Method Summary
Modifier and TypeMethodDescriptionaddAdapter(JsonTypeAdapter<?> adapter) Adds a type adapter to this module.addFactory(JsonTypeAdapterFactory factory) Adds a type adapter factory to this module.addKeyAdapter(Class<?> type, JsonTypeAdapter<?> adapter) Adds a key adapter to this module.Adds a mixin mapping to this module.List<JsonTypeAdapter<?>> Returns the registered adapters.Returns the registered factories.Map<Class<?>, JsonTypeAdapter<?>> Returns the registered key adapters.Returns the registered mixins.getName()Returns the module name.Returns the module version.voidsetupModule(JsonModule.SetupContext context) Configures the module using the provided setup context.toString()
-
Constructor Details
-
SimpleModule
-
-
Method Details
-
getName
Description copied from interface:JsonModuleReturns the module name. 返回模块名称。- Specified by:
getNamein interfaceJsonModule- Returns:
- the module name - 模块名称
-
getVersion
Description copied from interface:JsonModuleReturns the module version. 返回模块版本。- Specified by:
getVersionin interfaceJsonModule- Returns:
- the module version - 模块版本
-
addAdapter
Adds a type adapter to this module. 向此模块添加类型适配器。- Parameters:
adapter- the adapter to add - 要添加的适配器- Returns:
- this module for chaining - 此模块,用于链式调用
-
addFactory
Adds a type adapter factory to this module. 向此模块添加类型适配器工厂。- Parameters:
factory- the factory to add - 要添加的工厂- Returns:
- this module for chaining - 此模块,用于链式调用
-
addMixin
Adds a mixin mapping to this module. 向此模块添加混入映射。- Parameters:
target- the target class - 目标类mixin- the mixin class - 混入类- Returns:
- this module for chaining - 此模块,用于链式调用
-
addKeyAdapter
Adds a key adapter to this module. 向此模块添加键适配器。- Parameters:
type- the key type - 键类型adapter- the key adapter - 键适配器- Returns:
- this module for chaining - 此模块,用于链式调用
-
getAdapters
Returns the registered adapters. 返回注册的适配器。- Returns:
- unmodifiable list of adapters - 不可修改的适配器列表
-
getFactories
Returns the registered factories. 返回注册的工厂。- Returns:
- unmodifiable list of factories - 不可修改的工厂列表
-
getMixins
-
getKeyAdapters
Returns the registered key adapters. 返回注册的键适配器。- Returns:
- unmodifiable map of key adapters - 不可修改的键适配器映射
-
setupModule
Description copied from interface:JsonModuleConfigures the module using the provided setup context. 使用提供的设置上下文配置模块。- Specified by:
setupModulein interfaceJsonModule- Parameters:
context- the setup context for registering components - 用于注册组件的设置上下文
-
toString
-