public interface Dict
Implementations of this interface define a structured way to associate a code (typically stored in the database)
with a dictionary namespace (called dictName) to facilitate localized text retrieval.
null or "*") from code().
Their primary purpose is to define the dictName(), which acts as a configuration anchor.
Tools such as the dict-i18n-generator-maven-plugin will include both Enum and JavaBean-based implementations
when generating configuration files (e.g. YML, SQL), ensuring users can conveniently manage all dictionary sources.
Note: Runtime features that enumerate all dictionary items (e.g. web API /dict/items)
only support Enum-based dictionaries, as JavaBean implementations are designed to work with dynamic data sources
(e.g. MySQL, Redis) where dictionary codes are determined externally at runtime.
public enum OrderStatus implements Dict {
PENDING("pending"),
SHIPPED("shipped");
private final String code;
OrderStatus(String code) {
this.code = code;
}String dictName()
Typically formatted like "order_status", this value is used as part of
the lookup key when resolving localized text (e.g. order_status.PENDING).
Important: If Dict is implemented by an enum,
all enum constants in the same enum class must return the same dictName.
Returning different values will result in undefined behavior in dictionary scanning,
caching, or configuration generation.
String code()
This value usually comes from the business object (e.g. database field), and is used to match against the localized dictionary value.
Copyright © 2025. All rights reserved.