Source:
<code>private ConnectionContainer upsertOrUpdateObjects( Environment context, Executor updateFunc, RelationshipOp operation ) { if (context.ids.isPresent()) { throw new BadRequestException(operation + " must not include ids"); } if (!context.data.isPresent()) { throw new BadRequestException(operation + " must include data argument"); } Class<?> entityClass; EntityDictionary dictionary = context.requestScope.getDictionary(); if (context.isRoot()) { entityClass = dictionary.getEntityClass(context.field.getName()); } else { assert context.parentResource != null; entityClass = dictionary.getParameterizedType( context.parentResource.getResourceClass(), context.field.getName()); } Optional<Entity> parentEntity; if (!context.isRoot()) { <START> parentEntity = Optional.of(new Entity(Optional.empty(), null, entityClass, context.requestScope)); <END> } else { parentEntity = Optional.empty(); } LinkedHashSet<Entity> entitySet = new LinkedHashSet<>(); for (Map<String, Object> input : context.data.get()) { entitySet.add(new Entity(parentEntity, input, entityClass, context.requestScope)); } for (Entity entity : entitySet) { graphWalker(entity, updateFunc); } for (Entity entity : entitySet) { graphWalker(entity, this::updateRelationship); if (!context.isRoot()) { assert context.parentResource != null; context.parentResource.addRelation(context.field.getName(), entity.toPersistentResource()); } } String entityName = dictionary.getJsonAliasFor(entityClass); Set<PersistentResource> resources = entitySet.stream() .map(Entity::toPersistentResource) .collect(Collectors.toCollection(LinkedHashSet::new)); return new ConnectionContainer(resources, Optional.empty(), entityName); }</code><technical_language>type of parentEntity entityClass? This match code</technical_language>

Target:
private ConnectionContainer upsertOrUpdateObjects( Environment context, Executor updateFunc, RelationshipOp operation ) { if (context.ids.isPresent()) { throw new BadRequestException(operation + " must not include ids"); } if (!context.data.isPresent()) { throw new BadRequestException(operation + " must include data argument"); } Class<?> entityClass; EntityDictionary dictionary = context.requestScope.getDictionary(); if (context.isRoot()) { entityClass = dictionary.getEntityClass(context.field.getName()); } else { assert context.parentResource != null; entityClass = dictionary.getParameterizedType( context.parentResource.getResourceClass(), context.field.getName()); } Optional<Entity> parentEntity; if (!context.isRoot()) { assert context.parentResource != null; parentEntity = Optional.of(new Entity( Optional.empty(), null, context.parentResource.getResourceClass(), context.requestScope)); } else { parentEntity = Optional.empty(); } LinkedHashSet<Entity> entitySet = new LinkedHashSet<>(); for (Map<String, Object> input : context.data.get()) { entitySet.add(new Entity(parentEntity, input, entityClass, context.requestScope)); } for (Entity entity : entitySet) { graphWalker(entity, updateFunc); } for (Entity entity : entitySet) { graphWalker(entity, this::updateRelationship); if (!context.isRoot()) { assert context.parentResource != null; context.parentResource.addRelation(context.field.getName(), entity.toPersistentResource()); } } String entityName = dictionary.getJsonAliasFor(entityClass); Set<PersistentResource> resources = entitySet.stream() .map(Entity::toPersistentResource) .collect(Collectors.toCollection(LinkedHashSet::new)); return new ConnectionContainer(resources, Optional.empty(), entityName); }