Skip to content

Commit

Permalink
Remove root argument from buildMappers method (#89390)
Browse files Browse the repository at this point in the history
The callers of buildMappers can provide the right context, instead of passing a boolean
argument that controls what context is used.
  • Loading branch information
javanna authored Aug 17, 2022
1 parent c038a91 commit 695d1a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Builder includeInParent(boolean includeInParent) {

@Override
public NestedObjectMapper build(MapperBuilderContext context) {
return new NestedObjectMapper(name, context.buildFullName(name), buildMappers(false, context), this);
return new NestedObjectMapper(name, context.buildFullName(name), buildMappers(context.createChildContext(name)), this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ private static ObjectMapper.Builder findObjectBuilder(String fullName, DocumentP
throw new IllegalStateException("Missing intermediate object " + fullName);
}

protected final Map<String, Mapper> buildMappers(boolean root, MapperBuilderContext context) {
MapperBuilderContext mapperBuilderContext = root ? context : context.createChildContext(name);
protected final Map<String, Mapper> buildMappers(MapperBuilderContext mapperBuilderContext) {
Map<String, Mapper> mappers = new HashMap<>();
for (Mapper.Builder builder : mappersBuilders) {
Mapper mapper = builder.build(mapperBuilderContext);
Expand All @@ -164,7 +163,14 @@ protected final Map<String, Mapper> buildMappers(boolean root, MapperBuilderCont

@Override
public ObjectMapper build(MapperBuilderContext context) {
return new ObjectMapper(name, context.buildFullName(name), enabled, subobjects, dynamic, buildMappers(false, context));
return new ObjectMapper(
name,
context.buildFullName(name),
enabled,
subobjects,
dynamic,
buildMappers(context.createChildContext(name))
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public RootObjectMapper build(MapperBuilderContext context) {
enabled,
subobjects,
dynamic,
buildMappers(true, context),
buildMappers(context),
runtimeFields,
dynamicDateTimeFormatters,
dynamicTemplates,
Expand Down

0 comments on commit 695d1a8

Please sign in to comment.