/** * Adds a mapper as an update into the last mapper. If merge is true, the new mapper * will be merged in with other child mappers of the last parent, otherwise it will be a new update. */ private static void addToLastMapper(List<ObjectMapper> parentMappers, Mapper mapper, boolean merge) { assert parentMappers.size() >= 1; int lastIndex = parentMappers.size() - 1; ObjectMapper withNewMapper = parentMappers.get(lastIndex).mappingUpdate(mapper); if (merge) { withNewMapper = parentMappers.get(lastIndex).merge(withNewMapper, false); } parentMappers.set(lastIndex, withNewMapper); }
/** Build an update for the parent which will contain the given mapper and any intermediate fields. */ private static ObjectMapper createUpdate(ObjectMapper parent, String[] nameParts, int i, Mapper mapper) { List<ObjectMapper> parentMappers = new ArrayList<>(); ObjectMapper previousIntermediate = parent; for (; i < nameParts.length - 1; ++i) { Mapper intermediate = previousIntermediate.getMapper(nameParts[i]); assert intermediate != null : "Field " + previousIntermediate.name() + " does not have a subfield " + nameParts[i]; assert intermediate instanceof ObjectMapper; parentMappers.add((ObjectMapper)intermediate); previousIntermediate = (ObjectMapper)intermediate; } if (parentMappers.isEmpty() == false) { // add the new mapper to the stack, and pop down to the original parent level addToLastMapper(parentMappers, mapper, false); popMappers(parentMappers, 1, false); mapper = parentMappers.get(0); } return parent.mappingUpdate(mapper); }
@Override public ObjectMapper mappingUpdate(Mapper mapper) { RootObjectMapper update = (RootObjectMapper) super.mappingUpdate(mapper); // for dynamic updates, no need to carry root-specific options, we just // set everything to they implicit default value so that they are not // applied at merge time update.dynamicTemplates = new Explicit<>(new DynamicTemplate[0], false); update.dynamicDateTimeFormatters = new Explicit<>(Defaults.DYNAMIC_DATE_TIME_FORMATTERS, false); update.dateDetection = new Explicit<>(Defaults.DATE_DETECTION, false); update.numericDetection = new Explicit<>(Defaults.NUMERIC_DETECTION, false); return update; }
/** * Adds a mapper as an update into the last mapper. If merge is true, the new mapper * will be merged in with other child mappers of the last parent, otherwise it will be a new update. */ private static void addToLastMapper(List<ObjectMapper> parentMappers, Mapper mapper, boolean merge) { assert parentMappers.size() >= 1; int lastIndex = parentMappers.size() - 1; ObjectMapper withNewMapper = parentMappers.get(lastIndex).mappingUpdate(mapper); if (merge) { withNewMapper = parentMappers.get(lastIndex).merge(withNewMapper, false); } parentMappers.set(lastIndex, withNewMapper); }
/** * Adds a mapper as an update into the last mapper. If merge is true, the new mapper * will be merged in with other child mappers of the last parent, otherwise it will be a new update. */ private static void addToLastMapper(List<ObjectMapper> parentMappers, Mapper mapper, boolean merge) { assert parentMappers.size() >= 1; int lastIndex = parentMappers.size() - 1; ObjectMapper withNewMapper = parentMappers.get(lastIndex).mappingUpdate(mapper); if (merge) { withNewMapper = parentMappers.get(lastIndex).merge(withNewMapper, false); } parentMappers.set(lastIndex, withNewMapper); }
/** * Adds a mapper as an update into the last mapper. If merge is true, the new mapper * will be merged in with other child mappers of the last parent, otherwise it will be a new update. */ private static void addToLastMapper(List<ObjectMapper> parentMappers, Mapper mapper, boolean merge) { assert parentMappers.size() >= 1; int lastIndex = parentMappers.size() - 1; ObjectMapper withNewMapper = parentMappers.get(lastIndex).mappingUpdate(mapper); if (merge) { withNewMapper = parentMappers.get(lastIndex).merge(withNewMapper, false); } parentMappers.set(lastIndex, withNewMapper); }
/** Build an update for the parent which will contain the given mapper and any intermediate fields. */ private static ObjectMapper createUpdate(ObjectMapper parent, String[] nameParts, int i, Mapper mapper) { List<ObjectMapper> parentMappers = new ArrayList<>(); ObjectMapper previousIntermediate = parent; for (; i < nameParts.length - 1; ++i) { Mapper intermediate = previousIntermediate.getMapper(nameParts[i]); assert intermediate != null : "Field " + previousIntermediate.name() + " does not have a subfield " + nameParts[i]; assert intermediate instanceof ObjectMapper; parentMappers.add((ObjectMapper)intermediate); previousIntermediate = (ObjectMapper)intermediate; } if (parentMappers.isEmpty() == false) { // add the new mapper to the stack, and pop down to the original parent level addToLastMapper(parentMappers, mapper, false); popMappers(parentMappers, 1, false); mapper = parentMappers.get(0); } return parent.mappingUpdate(mapper); }
/** Build an update for the parent which will contain the given mapper and any intermediate fields. */ private static ObjectMapper createUpdate(ObjectMapper parent, String[] nameParts, int i, Mapper mapper) { List<ObjectMapper> parentMappers = new ArrayList<>(); ObjectMapper previousIntermediate = parent; for (; i < nameParts.length - 1; ++i) { Mapper intermediate = previousIntermediate.getMapper(nameParts[i]); assert intermediate != null : "Field " + previousIntermediate.name() + " does not have a subfield " + nameParts[i]; assert intermediate instanceof ObjectMapper; parentMappers.add((ObjectMapper)intermediate); previousIntermediate = (ObjectMapper)intermediate; } if (parentMappers.isEmpty() == false) { // add the new mapper to the stack, and pop down to the original parent level addToLastMapper(parentMappers, mapper, false); popMappers(parentMappers, 1, false); mapper = parentMappers.get(0); } return parent.mappingUpdate(mapper); }
/** Build an update for the parent which will contain the given mapper and any intermediate fields. */ private static ObjectMapper createUpdate(ObjectMapper parent, String[] nameParts, int i, Mapper mapper) { List<ObjectMapper> parentMappers = new ArrayList<>(); ObjectMapper previousIntermediate = parent; for (; i < nameParts.length - 1; ++i) { Mapper intermediate = previousIntermediate.getMapper(nameParts[i]); assert intermediate != null : "Field " + previousIntermediate.name() + " does not have a subfield " + nameParts[i]; assert intermediate instanceof ObjectMapper; parentMappers.add((ObjectMapper)intermediate); previousIntermediate = (ObjectMapper)intermediate; } if (parentMappers.isEmpty() == false) { // add the new mapper to the stack, and pop down to the original parent level addToLastMapper(parentMappers, mapper, false); popMappers(parentMappers, 1, false); mapper = parentMappers.get(0); } return parent.mappingUpdate(mapper); }
@Override public ObjectMapper mappingUpdate(Mapper mapper) { RootObjectMapper update = (RootObjectMapper) super.mappingUpdate(mapper); // for dynamic updates, no need to carry root-specific options, we just // set everything to they implicit default value so that they are not // applied at merge time update.dynamicTemplates = new Explicit<>(new DynamicTemplate[0], false); update.dynamicDateTimeFormatters = new Explicit<FormatDateTimeFormatter[]>(Defaults.DYNAMIC_DATE_TIME_FORMATTERS, false); update.dateDetection = new Explicit<>(Defaults.DATE_DETECTION, false); update.numericDetection = new Explicit<>(Defaults.NUMERIC_DETECTION, false); return update; }
@Override public ObjectMapper mappingUpdate(Mapper mapper) { RootObjectMapper update = (RootObjectMapper) super.mappingUpdate(mapper); // for dynamic updates, no need to carry root-specific options, we just // set everything to they implicit default value so that they are not // applied at merge time update.dynamicTemplates = new Explicit<>(new DynamicTemplate[0], false); update.dynamicDateTimeFormatters = new Explicit<FormatDateTimeFormatter[]>(Defaults.DYNAMIC_DATE_TIME_FORMATTERS, false); update.dateDetection = new Explicit<>(Defaults.DATE_DETECTION, false); update.numericDetection = new Explicit<>(Defaults.NUMERIC_DETECTION, false); return update; }
@Override public ObjectMapper mappingUpdate(Mapper mapper) { RootObjectMapper update = (RootObjectMapper) super.mappingUpdate(mapper); // for dynamic updates, no need to carry root-specific options, we just // set everything to they implicit default value so that they are not // applied at merge time update.dynamicTemplates = new Explicit<>(new DynamicTemplate[0], false); update.dynamicDateTimeFormatters = new Explicit<FormatDateTimeFormatter[]>(Defaults.DYNAMIC_DATE_TIME_FORMATTERS, false); update.dateDetection = new Explicit<>(Defaults.DATE_DETECTION, false); update.numericDetection = new Explicit<>(Defaults.NUMERIC_DETECTION, false); return update; }