Class MLFieldSerializerHandler
java.lang.Object
com.jalios.jcms.restv2.serializer.MLFieldSerializerHandler
Utility class responsible for handling multilingual (ML) field serialization.
This handler generates a language-aware JSON representation of a field by resolving its multilingual values when available. It supports:
- Extraction of ML values via a convention-based getter (e.g.
getTitleML()) - Fallback to the default field value when no ML data is available
- Only includes the languages explicitly requested in the serialization context
- Automatic fallback to the user's main language when a requested translation is missing
The resulting JSON structure is a map of language codes to their corresponding values.
Language selection is driven by CustomJsonSerializer, which provides
the list of requested languages via a ThreadLocal context.
If no specific languages are requested:
- All available ML values are returned (if present)
- The default value is ensured for the user's main language
If specific languages are requested:
- Only those languages are included
- Missing translations fall back to the main language or default value
Reflection is used to dynamically resolve ML getters based on field names.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidhandleMLField(com.fasterxml.jackson.core.JsonGenerator jgen, Object obj, org.apache.log4j.Logger logger, String fieldName, Class<T> clazz)
-
Constructor Details
-
MLFieldSerializerHandler
public MLFieldSerializerHandler()
-
-
Method Details
-
handleMLField
public static <T> void handleMLField(com.fasterxml.jackson.core.JsonGenerator jgen, Object obj, org.apache.log4j.Logger logger, String fieldName, Class<T> clazz) throws IOException - Throws:
IOException
-