Skip to content

#2322 potential fix#2342

Open
filiphr wants to merge 2 commits intomainfrom
2322
Open

#2322 potential fix#2342
filiphr wants to merge 2 commits intomainfrom
2322

Conversation

@filiphr
Copy link
Copy Markdown
Member

@filiphr filiphr commented Jan 23, 2021

No description provided.

@filiphr filiphr mentioned this pull request Jan 23, 2021
Copy link
Copy Markdown
Contributor

@sjaakd sjaakd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my first glance and the solution is complex. I'm having troubles to see the full impact. Which makes me think: do we need to add more testcases for this one? What else did we miss when we introduced the 'target-this' feature.?

For instance: the target mapping with "." now acts as a template and we have a balanced property mapping underneath it (source and target make the same step in nesting). What if its unbalanced and the 'template overriding mapping' maps a deeper nested target to a shallower nested source or vice versa? What if you've got combinations?

I'm still not understanding the essence of the solution. We already have "." mappings and methods handling the "target this". So, what is different in this scenario that we have to generate a new TargetReference reflecting the "." mapping in the middle of a handling routine? Did we miss something prior? Again. It could be a comment thing.

I guess it becomes more understandable if we add comments explaining a particular scenario we try to solve.

Also, the issue mentioned the source = ".".. I think we need to open (perhaps a separate PR) to

  1. actively replace this with the source parameter if there's one source param only or, issue an error when there's more than one source param
  2. Simply not allow it and give an error straight away.

But not leave it in the open.

String property = first( targetReference.getPropertyEntries() );
MappingReference newMapping = mapping.popTargetReference();

if ( newMapping == null && method.getSourceParameters().size() == 1 && sourceReference != null && sourceReference.getParameter() != null &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add some examples here in the code. . I'm pretty lost here (so an actual example).

Also we have a lot of checks on whether there are more source-parameters in our bean mapping. WDYT? is it interesting to factor this case out (in the future) in its own BeanMappingMethod e.g. MultipleSourceBeanMappingMethod?

List<String> newPathProperties = new ArrayList<>( targetReference.getPathProperties() );
newPathProperties.add( targetReference.getPropertyEntries().get( 0 ) );
TargetReference newTargetReference = new TargetReference( null, Collections.singletonList( "." ), newPathProperties);
newMapping = new MappingReference( mapping.getMapping(), newTargetReference, sourceReference );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what you are doing here is creating a new "." mapping when you only have a source parameter (no properties) in the mapping.. But then I get lost...

sourceReference.getPropertyEntries().isEmpty() &&
!targetReference.getPropertyEntries().isEmpty() ) {
List<String> newPathProperties = new ArrayList<>( targetReference.getPathProperties() );
newPathProperties.add( targetReference.getPropertyEntries().get( 0 ) );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TargetReference#getShallowestPropertyName

Set<MappingReference> singleTargetReferences) {
Set<MappingReference> mappings = entryByParam.getValue();
Set<MappingReference> nonNested = new LinkedHashSet<>();
NestedReferences nonNested = new NestedReferences();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels contradictory: assigning 'nonNested' to a type 'NestedReferences'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants