mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
This commit is contained in:
parent
74a2e358e8
commit
efea2fb662
@ -352,16 +352,12 @@ public class NestedTargetPropertyMappingHolder {
|
|||||||
MappingReference newMapping = mapping.popTargetReference();
|
MappingReference newMapping = mapping.popTargetReference();
|
||||||
if ( newMapping != null ) {
|
if ( newMapping != null ) {
|
||||||
// group properties on current name.
|
// group properties on current name.
|
||||||
if ( !mappingsKeyedByProperty.containsKey( property ) ) {
|
mappingsKeyedByProperty.computeIfAbsent( property, propertyEntry -> new LinkedHashSet<>() )
|
||||||
mappingsKeyedByProperty.put( property, new LinkedHashSet<>() );
|
.add( newMapping );
|
||||||
}
|
|
||||||
mappingsKeyedByProperty.get( property ).add( newMapping );
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( !singleTargetReferences.containsKey( property ) ) {
|
singleTargetReferences.computeIfAbsent( property, propertyEntry -> new LinkedHashSet<>() )
|
||||||
singleTargetReferences.put( property, new LinkedHashSet<>() );
|
.add( mapping );
|
||||||
}
|
|
||||||
singleTargetReferences.get( property ).add( mapping );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,10 +455,8 @@ public class NestedTargetPropertyMappingHolder {
|
|||||||
for ( MappingReference mapping : mappings ) {
|
for ( MappingReference mapping : mappings ) {
|
||||||
if ( mapping.getSourceReference() != null && mapping.getSourceReference().isValid() ) {
|
if ( mapping.getSourceReference() != null && mapping.getSourceReference().isValid() ) {
|
||||||
Parameter parameter = mapping.getSourceReference().getParameter();
|
Parameter parameter = mapping.getSourceReference().getParameter();
|
||||||
if ( !mappingsKeyedByParameter.containsKey( parameter ) ) {
|
mappingsKeyedByParameter.computeIfAbsent( parameter, key -> new LinkedHashSet<>() )
|
||||||
mappingsKeyedByParameter.put( parameter, new LinkedHashSet<>() );
|
.add( mapping );
|
||||||
}
|
|
||||||
mappingsKeyedByParameter.get( parameter ).add( mapping );
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
appliesToAll.add( mapping );
|
appliesToAll.add( mapping );
|
||||||
@ -530,10 +524,8 @@ public class NestedTargetPropertyMappingHolder {
|
|||||||
if ( newMapping != null ) {
|
if ( newMapping != null ) {
|
||||||
// group properties on current name.
|
// group properties on current name.
|
||||||
PropertyEntry property = first( mapping.getSourceReference().getPropertyEntries() );
|
PropertyEntry property = first( mapping.getSourceReference().getPropertyEntries() );
|
||||||
if ( !mappingsKeyedByProperty.containsKey( property ) ) {
|
mappingsKeyedByProperty.computeIfAbsent( property, propertyEntry -> new LinkedHashSet<>() )
|
||||||
mappingsKeyedByProperty.put( property, new LinkedHashSet<>() );
|
.add( newMapping );
|
||||||
}
|
|
||||||
mappingsKeyedByProperty.get( property ).add( newMapping );
|
|
||||||
}
|
}
|
||||||
//This is an ignore, or some expression, or a default. We apply these to all
|
//This is an ignore, or some expression, or a default. We apply these to all
|
||||||
else if ( mapping.getSourceReference() == null ) {
|
else if ( mapping.getSourceReference() == null ) {
|
||||||
@ -666,8 +658,8 @@ public class NestedTargetPropertyMappingHolder {
|
|||||||
for ( MappingReference mapping : singleTargetReferences ) {
|
for ( MappingReference mapping : singleTargetReferences ) {
|
||||||
if ( mapping.getSourceReference() != null && mapping.getSourceReference().isValid() ) {
|
if ( mapping.getSourceReference() != null && mapping.getSourceReference().isValid() ) {
|
||||||
K key = keyExtractor.apply( mapping.getSourceReference() );
|
K key = keyExtractor.apply( mapping.getSourceReference() );
|
||||||
if ( key != null && !map.containsKey( key ) ) {
|
if ( key != null ) {
|
||||||
map.put( key, new LinkedHashSet<>() );
|
map.computeIfAbsent( key, keyValue -> new LinkedHashSet<>() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,23 +485,21 @@ public class Type extends ModelElement implements Comparable<Type> {
|
|||||||
// In the DefaultAccessorNamingStrategy, this can only be the case for Booleans: isFoo() and
|
// In the DefaultAccessorNamingStrategy, this can only be the case for Booleans: isFoo() and
|
||||||
// getFoo(); The latter is preferred.
|
// getFoo(); The latter is preferred.
|
||||||
if ( !getter.getSimpleName().toString().startsWith( "is" ) ) {
|
if ( !getter.getSimpleName().toString().startsWith( "is" ) ) {
|
||||||
modifiableGetters.put( getPropertyName( getter ), getter );
|
modifiableGetters.put( propertyName, getter );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
modifiableGetters.put( getPropertyName( getter ), getter );
|
modifiableGetters.put( propertyName, getter );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Accessor> fieldsList = filters.fieldsIn( getAllFields() );
|
List<Accessor> fieldsList = filters.fieldsIn( getAllFields() );
|
||||||
for ( Accessor field : fieldsList ) {
|
for ( Accessor field : fieldsList ) {
|
||||||
String propertyName = getPropertyName( field );
|
String propertyName = getPropertyName( field );
|
||||||
if ( !modifiableGetters.containsKey( propertyName ) ) {
|
|
||||||
// If there was no getter or is method for booleans, then resort to the field.
|
// If there was no getter or is method for booleans, then resort to the field.
|
||||||
// If a field was already added do not add it again.
|
// If a field was already added do not add it again.
|
||||||
modifiableGetters.put( propertyName, field );
|
modifiableGetters.putIfAbsent( propertyName, field );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
readAccessors = Collections.unmodifiableMap( modifiableGetters );
|
readAccessors = Collections.unmodifiableMap( modifiableGetters );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user