mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
Fix warning addAll in org.mapstruct.ap.internal.model.assignment
Fix typo in org.mapstruct.ap.internal.model.common.Type
This commit is contained in:
parent
5f2a53afe1
commit
e5c5550182
@ -387,7 +387,7 @@ public class BeanMappingMethod extends NormalTypeMappingMethod {
|
|||||||
private boolean canBeConstructed(Type typeToBeConstructed) {
|
private boolean canBeConstructed(Type typeToBeConstructed) {
|
||||||
return !typeToBeConstructed.isAbstract()
|
return !typeToBeConstructed.isAbstract()
|
||||||
&& typeToBeConstructed.isAssignableTo( this.method.getResultType() )
|
&& typeToBeConstructed.isAssignableTo( this.method.getResultType() )
|
||||||
&& typeToBeConstructed.hasEmptyAccessibleContructor();
|
&& typeToBeConstructed.hasEmptyAccessibleConstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportResultTypeFromBeanMappingNotConstructableError(Type resultType) {
|
private void reportResultTypeFromBeanMappingNotConstructableError(Type resultType) {
|
||||||
@ -410,7 +410,7 @@ public class BeanMappingMethod extends NormalTypeMappingMethod {
|
|||||||
method.getResultType()
|
method.getResultType()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ( !resultType.hasEmptyAccessibleContructor() ) {
|
else if ( !resultType.hasEmptyAccessibleConstructor() ) {
|
||||||
ctx.getMessager().printMessage(
|
ctx.getMessager().printMessage(
|
||||||
method.getExecutable(),
|
method.getExecutable(),
|
||||||
BeanMappingPrism.getInstanceOn( method.getExecutable() ).mirror,
|
BeanMappingPrism.getInstanceOn( method.getExecutable() ).mirror,
|
||||||
@ -428,7 +428,7 @@ public class BeanMappingMethod extends NormalTypeMappingMethod {
|
|||||||
returnType
|
returnType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ( !returnType.hasEmptyAccessibleContructor() ) {
|
else if ( !returnType.hasEmptyAccessibleConstructor() ) {
|
||||||
ctx.getMessager().printMessage(
|
ctx.getMessager().printMessage(
|
||||||
method.getExecutable(),
|
method.getExecutable(),
|
||||||
Message.GENERAL_NO_SUITABLE_CONSTRUCTOR,
|
Message.GENERAL_NO_SUITABLE_CONSTRUCTOR,
|
||||||
|
@ -74,8 +74,7 @@ public class AdderWrapper extends AssignmentWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> getImportTypes() {
|
public Set<Type> getImportTypes() {
|
||||||
Set<Type> imported = new HashSet<>();
|
Set<Type> imported = new HashSet<>( super.getImportTypes() );
|
||||||
imported.addAll( super.getImportTypes() );
|
|
||||||
imported.add( adderType.getTypeBound() );
|
imported.add( adderType.getTypeBound() );
|
||||||
return imported;
|
return imported;
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,7 @@ public class ArrayCopyWrapper extends AssignmentWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> getImportTypes() {
|
public Set<Type> getImportTypes() {
|
||||||
Set<Type> imported = new HashSet<>();
|
Set<Type> imported = new HashSet<>( getAssignment().getImportTypes() );
|
||||||
imported.addAll( getAssignment().getImportTypes() );
|
|
||||||
imported.add( arraysType );
|
imported.add( arraysType );
|
||||||
imported.add( targetType );
|
imported.add( targetType );
|
||||||
return imported;
|
return imported;
|
||||||
|
@ -60,7 +60,7 @@ public class ExistingInstanceSetterWrapperForCollectionsAndMaps
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> getImportTypes() {
|
public Set<Type> getImportTypes() {
|
||||||
Set<Type> imported = new HashSet<Type>( super.getImportTypes() );
|
Set<Type> imported = new HashSet<>( super.getImportTypes() );
|
||||||
if ( isMapNullToDefault() && ( targetType.getImplementationType() != null ) ) {
|
if ( isMapNullToDefault() && ( targetType.getImplementationType() != null ) ) {
|
||||||
imported.add( targetType.getImplementationType() );
|
imported.add( targetType.getImplementationType() );
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,7 @@ public class StreamAdderWrapper extends AssignmentWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> getImportTypes() {
|
public Set<Type> getImportTypes() {
|
||||||
Set<Type> imported = new HashSet<>();
|
Set<Type> imported = new HashSet<>( super.getImportTypes() );
|
||||||
imported.addAll( super.getImportTypes() );
|
|
||||||
imported.add( adderType.getTypeBound() );
|
imported.add( adderType.getTypeBound() );
|
||||||
return imported;
|
return imported;
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,7 @@ public class UpdateWrapper extends AssignmentWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> getImportTypes() {
|
public Set<Type> getImportTypes() {
|
||||||
Set<Type> imported = new HashSet<>();
|
Set<Type> imported = new HashSet<>( super.getImportTypes() );
|
||||||
imported.addAll( super.getImportTypes() );
|
|
||||||
if ( factoryMethod != null ) {
|
if ( factoryMethod != null ) {
|
||||||
imported.addAll( factoryMethod.getImportTypes() );
|
imported.addAll( factoryMethod.getImportTypes() );
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class Type extends ModelElement implements Comparable<Type> {
|
|||||||
|
|
||||||
private Type boundingBase = null;
|
private Type boundingBase = null;
|
||||||
|
|
||||||
private Boolean hasEmptyAccessibleContructor;
|
private Boolean hasEmptyAccessibleConstructor;
|
||||||
|
|
||||||
private final Filters filters;
|
private final Filters filters;
|
||||||
|
|
||||||
@ -1018,20 +1018,20 @@ public class Type extends ModelElement implements Comparable<Type> {
|
|||||||
return boundingBase;
|
return boundingBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasEmptyAccessibleContructor() {
|
public boolean hasEmptyAccessibleConstructor() {
|
||||||
|
|
||||||
if ( this.hasEmptyAccessibleContructor == null ) {
|
if ( this.hasEmptyAccessibleConstructor == null ) {
|
||||||
hasEmptyAccessibleContructor = false;
|
hasEmptyAccessibleConstructor = false;
|
||||||
List<ExecutableElement> constructors = ElementFilter.constructorsIn( typeElement.getEnclosedElements() );
|
List<ExecutableElement> constructors = ElementFilter.constructorsIn( typeElement.getEnclosedElements() );
|
||||||
for ( ExecutableElement constructor : constructors ) {
|
for ( ExecutableElement constructor : constructors ) {
|
||||||
if ( !constructor.getModifiers().contains( Modifier.PRIVATE )
|
if ( !constructor.getModifiers().contains( Modifier.PRIVATE )
|
||||||
&& constructor.getParameters().isEmpty() ) {
|
&& constructor.getParameters().isEmpty() ) {
|
||||||
hasEmptyAccessibleContructor = true;
|
hasEmptyAccessibleConstructor = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hasEmptyAccessibleContructor;
|
return hasEmptyAccessibleConstructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user