|
|
@@ -52,19 +52,23 @@ public class RootObjectMapper extends ObjectMapper {
|
|
|
static final String TOXCONTENT_SKIP_RUNTIME = "skip_runtime";
|
|
|
|
|
|
public static class Defaults {
|
|
|
- public static final DateFormatter[] DYNAMIC_DATE_TIME_FORMATTERS = new DateFormatter[] {
|
|
|
- DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER,
|
|
|
- DateFormatter.forPattern("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis") };
|
|
|
- public static final boolean DATE_DETECTION = true;
|
|
|
- public static final boolean NUMERIC_DETECTION = false;
|
|
|
+ public static final Explicit<DateFormatter[]> DYNAMIC_DATE_TIME_FORMATTERS = new Explicit<>(
|
|
|
+ new DateFormatter[] {
|
|
|
+ DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER,
|
|
|
+ DateFormatter.forPattern("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis") },
|
|
|
+ false
|
|
|
+ );
|
|
|
+ public static final Explicit<Boolean> DATE_DETECTION = Explicit.IMPLICIT_TRUE;
|
|
|
+ public static final Explicit<Boolean> NUMERIC_DETECTION = Explicit.IMPLICIT_FALSE;
|
|
|
+ private static final Explicit<DynamicTemplate[]> DYNAMIC_TEMPLATES = new Explicit<>(new DynamicTemplate[0], false);
|
|
|
}
|
|
|
|
|
|
public static class Builder extends ObjectMapper.Builder {
|
|
|
+ protected Explicit<DynamicTemplate[]> dynamicTemplates = Defaults.DYNAMIC_TEMPLATES;
|
|
|
+ protected Explicit<DateFormatter[]> dynamicDateTimeFormatters = Defaults.DYNAMIC_DATE_TIME_FORMATTERS;
|
|
|
|
|
|
- protected Explicit<DynamicTemplate[]> dynamicTemplates = new Explicit<>(new DynamicTemplate[0], false);
|
|
|
- protected Explicit<DateFormatter[]> dynamicDateTimeFormatters = new Explicit<>(Defaults.DYNAMIC_DATE_TIME_FORMATTERS, false);
|
|
|
- protected Explicit<Boolean> dateDetection = new Explicit<>(Defaults.DATE_DETECTION, false);
|
|
|
- protected Explicit<Boolean> numericDetection = new Explicit<>(Defaults.NUMERIC_DETECTION, false);
|
|
|
+ protected Explicit<Boolean> dateDetection = Defaults.DATE_DETECTION;
|
|
|
+ protected Explicit<Boolean> numericDetection = Defaults.NUMERIC_DETECTION;
|
|
|
protected Map<String, RuntimeField> runtimeFields;
|
|
|
|
|
|
public Builder(String name) {
|
|
|
@@ -213,10 +217,10 @@ public class RootObjectMapper extends ObjectMapper {
|
|
|
builder.dynamicTemplates(templates);
|
|
|
return true;
|
|
|
} else if (fieldName.equals("date_detection")) {
|
|
|
- builder.dateDetection = new Explicit<>(nodeBooleanValue(fieldNode, "date_detection"), true);
|
|
|
+ builder.dateDetection = Explicit.explicitBoolean(nodeBooleanValue(fieldNode, "date_detection"));
|
|
|
return true;
|
|
|
} else if (fieldName.equals("numeric_detection")) {
|
|
|
- builder.numericDetection = new Explicit<>(nodeBooleanValue(fieldNode, "numeric_detection"), true);
|
|
|
+ builder.numericDetection = Explicit.explicitBoolean(nodeBooleanValue(fieldNode, "numeric_detection"));
|
|
|
return true;
|
|
|
} else if (fieldName.equals("runtime")) {
|
|
|
if (fieldNode instanceof Map) {
|
|
|
@@ -273,10 +277,10 @@ public class RootObjectMapper extends ObjectMapper {
|
|
|
// for dynamic updates, no need to carry root-specific options, we just
|
|
|
// set everything to their implicit default value so that they are not
|
|
|
// applied at merge time
|
|
|
- copy.dynamicTemplates = new Explicit<>(new DynamicTemplate[0], false);
|
|
|
- copy.dynamicDateTimeFormatters = new Explicit<>(Defaults.DYNAMIC_DATE_TIME_FORMATTERS, false);
|
|
|
- copy.dateDetection = new Explicit<>(Defaults.DATE_DETECTION, false);
|
|
|
- copy.numericDetection = new Explicit<>(Defaults.NUMERIC_DETECTION, false);
|
|
|
+ copy.dynamicTemplates = Defaults.DYNAMIC_TEMPLATES;
|
|
|
+ copy.dynamicDateTimeFormatters = Defaults.DYNAMIC_DATE_TIME_FORMATTERS;
|
|
|
+ copy.dateDetection = Defaults.DATE_DETECTION;
|
|
|
+ copy.numericDetection = Defaults.NUMERIC_DETECTION;
|
|
|
// also no need to carry the already defined runtime fields, only new ones need to be added
|
|
|
copy.runtimeFields.clear();
|
|
|
return copy;
|