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();
|
||||
if ( newMapping != null ) {
|
||||
// group properties on current name.
|
||||
if ( !mappingsKeyedByProperty.containsKey( property ) ) {
|
||||
mappingsKeyedByProperty.put( property, new LinkedHashSet<>() );
|
||||
}
|
||||
mappingsKeyedByProperty.get( property ).add( newMapping );
|
||||
mappingsKeyedByProperty.computeIfAbsent( property, propertyEntry -> new LinkedHashSet<>() )
|
||||
.add( newMapping );
|
||||
}
|
||||
else {
|
||||
if ( !singleTargetReferences.containsKey( property ) ) {
|
||||
singleTargetReferences.put( property, new LinkedHashSet<>() );
|
||||
}
|
||||
singleTargetReferences.get( property ).add( mapping );
|
||||
singleTargetReferences.computeIfAbsent( property, propertyEntry -> new LinkedHashSet<>() )
|
||||
.add( mapping );
|
||||
}
|
||||
}
|
||||
|
||||
@ -459,10 +455,8 @@ public class NestedTargetPropertyMappingHolder {
|
||||
for ( MappingReference mapping : mappings ) {
|
||||
if ( mapping.getSourceReference() != null && mapping.getSourceReference().isValid() ) {
|
||||
Parameter parameter = mapping.getSourceReference().getParameter();
|
||||
if ( !mappingsKeyedByParameter.containsKey( parameter ) ) {
|
||||
mappingsKeyedByParameter.put( parameter, new LinkedHashSet<>() );
|
||||
}
|
||||
mappingsKeyedByParameter.get( parameter ).add( mapping );
|
||||
mappingsKeyedByParameter.computeIfAbsent( parameter, key -> new LinkedHashSet<>() )
|
||||
.add( mapping );
|
||||
}
|
||||
else {
|
||||
appliesToAll.add( mapping );
|
||||
@ -530,10 +524,8 @@ public class NestedTargetPropertyMappingHolder {
|
||||
if ( newMapping != null ) {
|
||||
// group properties on current name.
|
||||
PropertyEntry property = first( mapping.getSourceReference().getPropertyEntries() );
|
||||
if ( !mappingsKeyedByProperty.containsKey( property ) ) {
|
||||
mappingsKeyedByProperty.put( property, new LinkedHashSet<>() );
|
||||
}
|
||||
mappingsKeyedByProperty.get( property ).add( newMapping );
|
||||
mappingsKeyedByProperty.computeIfAbsent( property, propertyEntry -> new LinkedHashSet<>() )
|
||||
.add( newMapping );
|
||||
}
|
||||
//This is an ignore, or some expression, or a default. We apply these to all
|
||||
else if ( mapping.getSourceReference() == null ) {
|
||||
@ -666,8 +658,8 @@ public class NestedTargetPropertyMappingHolder {
|
||||
for ( MappingReference mapping : singleTargetReferences ) {
|
||||
if ( mapping.getSourceReference() != null && mapping.getSourceReference().isValid() ) {
|
||||
K key = keyExtractor.apply( mapping.getSourceReference() );
|
||||
if ( key != null && !map.containsKey( key ) ) {
|
||||
map.put( key, new LinkedHashSet<>() );
|
||||
if ( key != null ) {
|
||||
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
|
||||
// getFoo(); The latter is preferred.
|
||||
if ( !getter.getSimpleName().toString().startsWith( "is" ) ) {
|
||||
modifiableGetters.put( getPropertyName( getter ), getter );
|
||||
modifiableGetters.put( propertyName, getter );
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
modifiableGetters.put( getPropertyName( getter ), getter );
|
||||
modifiableGetters.put( propertyName, getter );
|
||||
}
|
||||
}
|
||||
|
||||
List<Accessor> fieldsList = filters.fieldsIn( getAllFields() );
|
||||
for ( Accessor field : fieldsList ) {
|
||||
String propertyName = getPropertyName( field );
|
||||
if ( !modifiableGetters.containsKey( propertyName ) ) {
|
||||
// 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.
|
||||
modifiableGetters.put( propertyName, 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.
|
||||
modifiableGetters.putIfAbsent( propertyName, field );
|
||||
}
|
||||
readAccessors = Collections.unmodifiableMap( modifiableGetters );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user