From bbeaa2117c76a44016798e142f5485d49fc68379 Mon Sep 17 00:00:00 2001 From: Gunnar Morling Date: Tue, 24 Feb 2015 23:46:18 +0100 Subject: [PATCH] #168 Formatting --- .../main/java/org/mapstruct/BeanMapping.java | 6 +-- .../mapstruct/CollectionMappingStrategy.java | 8 +-- .../org/mapstruct/InheritConfiguration.java | 4 +- .../InheritInverseConfiguration.java | 4 +- .../main/java/org/mapstruct/MapMapping.java | 6 ++- .../src/main/java/org/mapstruct/Mapper.java | 2 +- .../main/java/org/mapstruct/MapperConfig.java | 2 +- .../main/java/org/mapstruct/Qualifier.java | 4 +- .../java/org/mapstruct/factory/Mappers.java | 1 + .../ap/model/source/MappingOptions.java | 4 +- .../ap/processor/MapperCreationProcessor.java | 3 +- .../ap/util/MapperConfiguration.java | 10 ++-- .../AutoInheritedConfig.java | 8 +-- .../AutoInheritedDriverConfig.java | 10 ++-- .../inheritfromconfig/BaseVehicleDto.java | 1 - .../inheritfromconfig/BaseVehicleEntity.java | 1 - .../ap/test/inheritfromconfig/CarDto.java | 1 - .../ap/test/inheritfromconfig/CarEntity.java | 1 - .../CarMapperWithAutoInheritance.java | 17 +++--- .../CarMapperWithExplicitInheritance.java | 11 ++-- .../CarWithDriverEntity.java | 1 - ...arWithDriverMapperWithAutoInheritance.java | 3 +- .../ap/test/inheritfromconfig/DriverDto.java | 1 - .../inheritfromconfig/Erroneous1Config.java | 10 ++-- .../inheritfromconfig/Erroneous1Mapper.java | 11 ++-- .../inheritfromconfig/Erroneous2Mapper.java | 17 +++--- .../InheritFromConfigTest.java | 53 ++++++++++--------- 27 files changed, 96 insertions(+), 104 deletions(-) diff --git a/core-common/src/main/java/org/mapstruct/BeanMapping.java b/core-common/src/main/java/org/mapstruct/BeanMapping.java index 904edd8a9..723bc93f7 100644 --- a/core-common/src/main/java/org/mapstruct/BeanMapping.java +++ b/core-common/src/main/java/org/mapstruct/BeanMapping.java @@ -31,8 +31,8 @@ import java.lang.annotation.Target; * * @author Sjaak Derksen */ -@Target( ElementType.METHOD ) -@Retention( RetentionPolicy.SOURCE ) +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.SOURCE) public @interface BeanMapping { /** @@ -42,7 +42,7 @@ public @interface BeanMapping { */ Class resultType() default void.class; - /** + /** * A qualifier can be specified to aid the selection process of a suitable factory method. This is useful in * case multiple factory method (hand written of internal) qualify and result in an 'Ambiguous factory methods' * error. diff --git a/core-common/src/main/java/org/mapstruct/CollectionMappingStrategy.java b/core-common/src/main/java/org/mapstruct/CollectionMappingStrategy.java index 6fc9489c6..4b2debd31 100644 --- a/core-common/src/main/java/org/mapstruct/CollectionMappingStrategy.java +++ b/core-common/src/main/java/org/mapstruct/CollectionMappingStrategy.java @@ -27,19 +27,19 @@ public enum CollectionMappingStrategy { /** * The setter of the target property will be used to propagate the value: - * {@code orderDto.setOrderLines( order.getOrderLines )}. + * {@code orderDto.setOrderLines(order.getOrderLines)}. *

* If no setter is available but a getter method, this will be used, under the assumption it has been initialized: - * {@code orderDto.getOrderLines().addAll( order.getOrderLines )}. + * {@code orderDto.getOrderLines().addAll(order.getOrderLines)}. */ ACCESSOR_ONLY, /** * If present, the setter of the target property will be used to propagate the value: - * {@code orderDto.setOrderLines( order.getOrderLines )}. + * {@code orderDto.setOrderLines(order.getOrderLines)}. *

* If no setter but and adder method is present, that adder will be invoked for each element of the source - * collection: {@code order.addOrderLine( orderLine() )}. + * collection: {@code order.addOrderLine(orderLine() )}. *

* If neither a setter nor an adder method but a getter for the target property is present, that getter will be * used, assuming it returns an initialized collection: If no setter is available, MapStruct will first look for an diff --git a/core-common/src/main/java/org/mapstruct/InheritConfiguration.java b/core-common/src/main/java/org/mapstruct/InheritConfiguration.java index d9bba63dd..63d2a7a5b 100644 --- a/core-common/src/main/java/org/mapstruct/InheritConfiguration.java +++ b/core-common/src/main/java/org/mapstruct/InheritConfiguration.java @@ -49,8 +49,8 @@ import java.lang.annotation.Target; * * @author Sjaak Derksen */ -@Target( ElementType.METHOD ) -@Retention( RetentionPolicy.SOURCE ) +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.SOURCE) public @interface InheritConfiguration { /** diff --git a/core-common/src/main/java/org/mapstruct/InheritInverseConfiguration.java b/core-common/src/main/java/org/mapstruct/InheritInverseConfiguration.java index 47cb8c99b..d9c8d69c1 100644 --- a/core-common/src/main/java/org/mapstruct/InheritInverseConfiguration.java +++ b/core-common/src/main/java/org/mapstruct/InheritInverseConfiguration.java @@ -37,8 +37,8 @@ import java.lang.annotation.Target; * * @author Sjaak Derksen */ -@Target( ElementType.METHOD ) -@Retention( RetentionPolicy.SOURCE ) +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.SOURCE) public @interface InheritInverseConfiguration { /** diff --git a/core-common/src/main/java/org/mapstruct/MapMapping.java b/core-common/src/main/java/org/mapstruct/MapMapping.java index 0296d6de9..cb87d05b2 100644 --- a/core-common/src/main/java/org/mapstruct/MapMapping.java +++ b/core-common/src/main/java/org/mapstruct/MapMapping.java @@ -79,7 +79,8 @@ public @interface MapMapping { /** * Specifies the type of the key to be used in the result of the mapping method in case multiple mapping * methods qualify. - * * + * + * * @return the resultType to select */ Class keyTargetType() default void.class; @@ -87,7 +88,8 @@ public @interface MapMapping { /** * Specifies the type of the value to be used in the result of the mapping method in case multiple mapping * methods qualify. - * * + * + * * @return the resultType to select */ Class valueTargetType() default void.class; diff --git a/core-common/src/main/java/org/mapstruct/Mapper.java b/core-common/src/main/java/org/mapstruct/Mapper.java index 1503890a0..1e71500aa 100644 --- a/core-common/src/main/java/org/mapstruct/Mapper.java +++ b/core-common/src/main/java/org/mapstruct/Mapper.java @@ -123,7 +123,7 @@ public @interface Mapper { * applied, using {@link MappingInheritanceStrategy#EXPLICIT} as default. * * @return The strategy to use for applying {@code @Mapping} configurations of prototype methods in the interface - * specified with {@link #config()}. + * specified with {@link #config()}. */ MappingInheritanceStrategy mappingInheritanceStrategy() default MappingInheritanceStrategy.DEFAULT; } diff --git a/core-common/src/main/java/org/mapstruct/MapperConfig.java b/core-common/src/main/java/org/mapstruct/MapperConfig.java index 0b18b9b87..3cee92c29 100644 --- a/core-common/src/main/java/org/mapstruct/MapperConfig.java +++ b/core-common/src/main/java/org/mapstruct/MapperConfig.java @@ -109,7 +109,7 @@ public @interface MapperConfig { * If no strategy is configured, {@link MappingInheritanceStrategy#EXPLICIT} will be used as default. * * @return The strategy to use for applying {@code @Mapping} configurations of prototype methods in the interface - * annotated with this annotation. + * annotated with this annotation. */ MappingInheritanceStrategy mappingInheritanceStrategy() default MappingInheritanceStrategy.EXPLICIT; diff --git a/core-common/src/main/java/org/mapstruct/Qualifier.java b/core-common/src/main/java/org/mapstruct/Qualifier.java index dfc59febb..551ea5636 100644 --- a/core-common/src/main/java/org/mapstruct/Qualifier.java +++ b/core-common/src/main/java/org/mapstruct/Qualifier.java @@ -44,7 +44,7 @@ import java.lang.annotation.Target; * * @author Sjaak Derksen */ -@Target( ElementType.ANNOTATION_TYPE ) -@Retention( RetentionPolicy.CLASS ) +@Target(ElementType.ANNOTATION_TYPE) +@Retention(RetentionPolicy.CLASS) public @interface Qualifier { } diff --git a/core-common/src/main/java/org/mapstruct/factory/Mappers.java b/core-common/src/main/java/org/mapstruct/factory/Mappers.java index d32e1f39e..7afe79a9f 100644 --- a/core-common/src/main/java/org/mapstruct/factory/Mappers.java +++ b/core-common/src/main/java/org/mapstruct/factory/Mappers.java @@ -55,6 +55,7 @@ public class Mappers { * * @param clazz The type of the mapper to return. * @param The type of the mapper to create. + * * @return An instance of the given mapper type. */ public static T getMapper(Class clazz) { diff --git a/processor/src/main/java/org/mapstruct/ap/model/source/MappingOptions.java b/processor/src/main/java/org/mapstruct/ap/model/source/MappingOptions.java index f0db38a9e..6cc03eb2c 100644 --- a/processor/src/main/java/org/mapstruct/ap/model/source/MappingOptions.java +++ b/processor/src/main/java/org/mapstruct/ap/model/source/MappingOptions.java @@ -45,7 +45,7 @@ public class MappingOptions { /** * @return the {@link Mapping}s configured for this method, keyed by target property name. Only for enum mapping - * methods a target will be mapped by several sources. + * methods a target will be mapped by several sources. */ public Map> getMappings() { return mappings; @@ -73,7 +73,7 @@ public class MappingOptions { /** * @return the {@code true}, iff the options have been fully initialized by applying all available inheritance - * options + * options */ public boolean isFullyInitialized() { return fullyInitialized; diff --git a/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java b/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java index 961f06325..9802bc4fc 100644 --- a/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java +++ b/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java @@ -412,7 +412,8 @@ public class MapperCreationProcessor implements ModelElementProcessor rawMethods, SourceMethod method, - List initializingMethods, MapperConfiguration mapperConfig) { + List initializingMethods, + MapperConfiguration mapperConfig) { SourceMethod resultMethod = null; InheritInverseConfigurationPrism reversePrism = InheritInverseConfigurationPrism.getInstanceOn( method.getExecutable() diff --git a/processor/src/main/java/org/mapstruct/ap/util/MapperConfiguration.java b/processor/src/main/java/org/mapstruct/ap/util/MapperConfiguration.java index 750f9007a..27a36ed7b 100644 --- a/processor/src/main/java/org/mapstruct/ap/util/MapperConfiguration.java +++ b/processor/src/main/java/org/mapstruct/ap/util/MapperConfiguration.java @@ -29,8 +29,6 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; -import org.mapstruct.Mapper; -import org.mapstruct.MapperConfig; import org.mapstruct.ap.option.ReportingPolicy; import org.mapstruct.ap.prism.CollectionMappingStrategyPrism; import org.mapstruct.ap.prism.MapperConfigPrism; @@ -40,12 +38,12 @@ import org.mapstruct.ap.prism.NullValueMappingPrism; import org.mapstruct.ap.prism.NullValueMappingStrategyPrism; /** - * Provides an aggregated view to the settings given via {@link Mapper} and {@link MapperConfig} for a specific mapper - * class. + * Provides an aggregated view to the settings given via {@link org.mapstruct.Mapper} and + * {@link org.mapstruct.MapperConfig} for a specific mapper class. *

* Settings given via {@code Mapper} will generally take precedence over settings inherited from a referenced config - * class. The lists of referenced mappers given via {@link Mapper#uses()} and {@link MapperConfig#uses() } will be - * merged. + * class. The lists of referenced mappers given via {@link org.mapstruct.Mapper#uses()} and + * {@link org.mapstruct.MapperConfig#uses() } will be merged. * * @author Sjaak Derksen */ diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/AutoInheritedConfig.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/AutoInheritedConfig.java index 12c63ade8..cc64daf22 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/AutoInheritedConfig.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/AutoInheritedConfig.java @@ -32,9 +32,9 @@ import org.mapstruct.ReportingPolicy; unmappedTargetPolicy = ReportingPolicy.ERROR ) public interface AutoInheritedConfig { - @Mappings( { - @Mapping( target = "primaryKey", source = "id" ), - @Mapping( target = "auditTrail", ignore = true ) - } ) + @Mappings({ + @Mapping(target = "primaryKey", source = "id"), + @Mapping(target = "auditTrail", ignore = true) + }) BaseVehicleEntity baseDtoToEntity(BaseVehicleDto dto); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/AutoInheritedDriverConfig.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/AutoInheritedDriverConfig.java index 6e2e1764e..a742da2da 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/AutoInheritedDriverConfig.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/AutoInheritedDriverConfig.java @@ -32,10 +32,10 @@ import org.mapstruct.ReportingPolicy; unmappedTargetPolicy = ReportingPolicy.ERROR ) public interface AutoInheritedDriverConfig { - @Mappings( { - @Mapping( target = "primaryKey", source = "dto.id" ), - @Mapping( target = "auditTrail", ignore = true ), - @Mapping( target = "driverName", source = "drv.name" ) - } ) + @Mappings({ + @Mapping(target = "primaryKey", source = "dto.id"), + @Mapping(target = "auditTrail", ignore = true), + @Mapping(target = "driverName", source = "drv.name") + }) CarWithDriverEntity baseDtoToEntity(DriverDto drv, BaseVehicleDto dto); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/BaseVehicleDto.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/BaseVehicleDto.java index 17f725c22..f262be49d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/BaseVehicleDto.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/BaseVehicleDto.java @@ -20,7 +20,6 @@ package org.mapstruct.ap.test.inheritfromconfig; /** * @author Andreas Gudian - * */ public abstract class BaseVehicleDto { private long id; diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/BaseVehicleEntity.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/BaseVehicleEntity.java index a79024afb..940772f51 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/BaseVehicleEntity.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/BaseVehicleEntity.java @@ -20,7 +20,6 @@ package org.mapstruct.ap.test.inheritfromconfig; /** * @author Andreas Gudian - * */ public abstract class BaseVehicleEntity { private long primaryKey; diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarDto.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarDto.java index 9928a3e00..44d21fe39 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarDto.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarDto.java @@ -20,7 +20,6 @@ package org.mapstruct.ap.test.inheritfromconfig; /** * @author Andreas Gudian - * */ public class CarDto extends BaseVehicleDto { private String colour; diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarEntity.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarEntity.java index 080d93958..6c039edeb 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarEntity.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarEntity.java @@ -20,7 +20,6 @@ package org.mapstruct.ap.test.inheritfromconfig; /** * @author Andreas Gudian - * */ public class CarEntity extends BaseVehicleEntity { private String color; diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarMapperWithAutoInheritance.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarMapperWithAutoInheritance.java index 6f224352b..4274cd175 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarMapperWithAutoInheritance.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarMapperWithAutoInheritance.java @@ -28,7 +28,6 @@ import org.mapstruct.factory.Mappers; /** * @author Andreas Gudian - * */ @Mapper( config = AutoInheritedConfig.class @@ -36,21 +35,21 @@ import org.mapstruct.factory.Mappers; public interface CarMapperWithAutoInheritance { CarMapperWithAutoInheritance INSTANCE = Mappers.getMapper( CarMapperWithAutoInheritance.class ); - @Mapping( target = "color", source = "colour" ) + @Mapping(target = "color", source = "colour") CarEntity toCarEntity(CarDto carDto); - @InheritInverseConfiguration( name = "toCarEntity" ) + @InheritInverseConfiguration(name = "toCarEntity") CarDto toCarDto(CarEntity entity); - @Mappings( { - @Mapping( target = "color", source = "colour" ), - @Mapping( target = "auditTrail", constant = "fixed" ) - } ) + @Mappings({ + @Mapping(target = "color", source = "colour"), + @Mapping(target = "auditTrail", constant = "fixed") + }) CarEntity toCarEntityWithFixedAuditTrail(CarDto carDto); - @Mapping( target = "color", source = "colour" ) + @Mapping(target = "color", source = "colour") void intoCarEntityOnItsOwn(CarDto carDto, @MappingTarget CarEntity entity); - @InheritConfiguration( name = "toCarEntity" ) + @InheritConfiguration(name = "toCarEntity") void intoCarEntity(CarDto carDto, @MappingTarget CarEntity entity); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarMapperWithExplicitInheritance.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarMapperWithExplicitInheritance.java index 92d831627..507c379ad 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarMapperWithExplicitInheritance.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarMapperWithExplicitInheritance.java @@ -27,7 +27,6 @@ import org.mapstruct.factory.Mappers; /** * @author Andreas Gudian - * */ @Mapper( config = AutoInheritedConfig.class, @@ -36,14 +35,14 @@ import org.mapstruct.factory.Mappers; public interface CarMapperWithExplicitInheritance { CarMapperWithExplicitInheritance INSTANCE = Mappers.getMapper( CarMapperWithExplicitInheritance.class ); - @InheritConfiguration( name = "baseDtoToEntity" ) - @Mapping( target = "color", source = "colour" ) + @InheritConfiguration(name = "baseDtoToEntity") + @Mapping(target = "color", source = "colour") CarEntity toCarEntity(CarDto carDto); - @InheritInverseConfiguration( name = "toCarEntity" ) + @InheritInverseConfiguration(name = "toCarEntity") CarDto toCarDto(CarEntity entity); - @InheritConfiguration( name = "toCarEntity" ) - @Mapping( target = "auditTrail", constant = "fixed" ) + @InheritConfiguration(name = "toCarEntity") + @Mapping(target = "auditTrail", constant = "fixed") CarEntity toCarEntityWithFixedAuditTrail(CarDto carDto); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarWithDriverEntity.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarWithDriverEntity.java index ad41ed9b8..af4d8f7c8 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarWithDriverEntity.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarWithDriverEntity.java @@ -20,7 +20,6 @@ package org.mapstruct.ap.test.inheritfromconfig; /** * @author Andreas Gudian - * */ public class CarWithDriverEntity extends CarEntity { private String driverName; diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarWithDriverMapperWithAutoInheritance.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarWithDriverMapperWithAutoInheritance.java index 09c067800..d8ff0c024 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarWithDriverMapperWithAutoInheritance.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/CarWithDriverMapperWithAutoInheritance.java @@ -24,7 +24,6 @@ import org.mapstruct.factory.Mappers; /** * @author Andreas Gudian - * */ @Mapper( config = AutoInheritedDriverConfig.class @@ -32,6 +31,6 @@ import org.mapstruct.factory.Mappers; public interface CarWithDriverMapperWithAutoInheritance { CarWithDriverMapperWithAutoInheritance INSTANCE = Mappers.getMapper( CarWithDriverMapperWithAutoInheritance.class ); - @Mapping( target = "color", source = "carDto.colour" ) + @Mapping(target = "color", source = "carDto.colour") CarWithDriverEntity toCarWithDriverEntity(CarDto carDto, DriverDto driverDto); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/DriverDto.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/DriverDto.java index eefb6ef24..3f5bff18e 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/DriverDto.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/DriverDto.java @@ -20,7 +20,6 @@ package org.mapstruct.ap.test.inheritfromconfig; /** * @author Andreas Gudian - * */ public class DriverDto { private String name; diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous1Config.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous1Config.java index 4cb6b5015..be96a96e2 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous1Config.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous1Config.java @@ -34,12 +34,12 @@ import org.mapstruct.ReportingPolicy; unmappedTargetPolicy = ReportingPolicy.WARN ) public interface Erroneous1Config { - @Mappings( { - @Mapping( target = "primaryKey", source = "id" ), - @Mapping( target = "auditTrail", ignore = true ) - } ) + @Mappings({ + @Mapping(target = "primaryKey", source = "id"), + @Mapping(target = "auditTrail", ignore = true) + }) BaseVehicleEntity baseDtoToEntity(BaseVehicleDto dto); - @Mapping( target = "primaryKey", ignore = true ) + @Mapping(target = "primaryKey", ignore = true) BaseVehicleEntity anythingToEntity(Object anyting); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous1Mapper.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous1Mapper.java index ab33131bc..21e90deef 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous1Mapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous1Mapper.java @@ -25,7 +25,6 @@ import org.mapstruct.factory.Mappers; /** * @author Andreas Gudian - * */ @Mapper( config = Erroneous1Config.class @@ -33,12 +32,12 @@ import org.mapstruct.factory.Mappers; public interface Erroneous1Mapper { Erroneous1Mapper INSTANCE = Mappers.getMapper( Erroneous1Mapper.class ); - @Mapping( target = "color", source = "colour" ) + @Mapping(target = "color", source = "colour") CarEntity toCarEntity(CarDto carDto); - @Mappings( { - @Mapping( target = "color", source = "colour" ), - @Mapping( target = "auditTrail", constant = "fixed" ) - } ) + @Mappings({ + @Mapping(target = "color", source = "colour"), + @Mapping(target = "auditTrail", constant = "fixed") + }) CarEntity toCarEntityWithFixedAuditTrail(CarDto carDto); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous2Mapper.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous2Mapper.java index 35b990db0..2b92f8b7d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous2Mapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/Erroneous2Mapper.java @@ -27,7 +27,6 @@ import org.mapstruct.factory.Mappers; /** * @author Andreas Gudian - * */ @Mapper( config = AutoInheritedConfig.class @@ -35,17 +34,17 @@ import org.mapstruct.factory.Mappers; public interface Erroneous2Mapper { Erroneous2Mapper INSTANCE = Mappers.getMapper( Erroneous2Mapper.class ); - @InheritConfiguration( name = "toCarEntity2" ) + @InheritConfiguration(name = "toCarEntity2") CarEntity toCarEntity1(CarDto carDto); - @InheritConfiguration( name = "toCarEntity3" ) + @InheritConfiguration(name = "toCarEntity3") CarEntity toCarEntity2(CarDto carDto); - @InheritConfiguration( name = "toCarEntity1" ) - @Mappings( { - @Mapping( target = "color", ignore = true ), - @Mapping( target = "auditTrail", ignore = true ), - @Mapping( target = "primaryKey", ignore = true ) - } ) + @InheritConfiguration(name = "toCarEntity1") + @Mappings({ + @Mapping(target = "color", ignore = true), + @Mapping(target = "auditTrail", ignore = true), + @Mapping(target = "primaryKey", ignore = true) + }) void toCarEntity3(CarDto carDto, @MappingTarget CarEntity entity); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/InheritFromConfigTest.java b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/InheritFromConfigTest.java index df10a4bf0..b47de959c 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/InheritFromConfigTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritfromconfig/InheritFromConfigTest.java @@ -18,6 +18,8 @@ */ package org.mapstruct.ap.test.inheritfromconfig; +import static org.fest.assertions.Assertions.assertThat; + import javax.tools.Diagnostic.Kind; import org.junit.Test; @@ -29,22 +31,20 @@ import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic; import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; -import static org.fest.assertions.Assertions.assertThat; - /** * @author Andreas Gudian - * */ -@RunWith( AnnotationProcessorTestRunner.class ) -@WithClasses( { +@RunWith(AnnotationProcessorTestRunner.class) +@WithClasses({ BaseVehicleDto.class, BaseVehicleEntity.class, CarDto.class, CarEntity.class, CarMapperWithAutoInheritance.class, CarMapperWithExplicitInheritance.class, - AutoInheritedConfig.class } ) -@IssueKey( "168" ) + AutoInheritedConfig.class +}) +@IssueKey("168") public class InheritFromConfigTest { @Test @@ -145,11 +145,12 @@ public class InheritFromConfigTest { } @Test - @WithClasses( { + @WithClasses({ DriverDto.class, CarWithDriverEntity.class, CarWithDriverMapperWithAutoInheritance.class, - AutoInheritedDriverConfig.class } ) + AutoInheritedDriverConfig.class + }) public void autoInheritedFromMultipleSources() { CarDto carDto = newTestDto(); DriverDto driverDto = new DriverDto(); @@ -163,32 +164,32 @@ public class InheritFromConfigTest { } @Test - @WithClasses( { Erroneous1Mapper.class, Erroneous1Config.class } ) + @WithClasses({ Erroneous1Mapper.class, Erroneous1Config.class }) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic( type = Erroneous1Mapper.class, + @Diagnostic(type = Erroneous1Mapper.class, kind = Kind.ERROR, - line = 37, + line = 36, messageRegExp = "More than one configuration prototype method is applicable. Use @InheritConfiguration" + " to select one of them explicitly:" + " .*BaseVehicleEntity baseDtoToEntity\\(.*BaseVehicleDto dto\\)," - + " .*BaseVehicleEntity anythingToEntity\\(java.lang.Object anyting\\)\\." ), - @Diagnostic( type = Erroneous1Mapper.class, + + " .*BaseVehicleEntity anythingToEntity\\(java.lang.Object anyting\\)\\."), + @Diagnostic(type = Erroneous1Mapper.class, kind = Kind.WARNING, - line = 37, - messageRegExp = "Unmapped target properties: \"auditTrail, primaryKey\"\\." ), - @Diagnostic( type = Erroneous1Mapper.class, + line = 36, + messageRegExp = "Unmapped target properties: \"auditTrail, primaryKey\"\\."), + @Diagnostic(type = Erroneous1Mapper.class, kind = Kind.ERROR, - line = 43, + line = 42, messageRegExp = "More than one configuration prototype method is applicable. Use @InheritConfiguration" + " to select one of them explicitly:" + " .*BaseVehicleEntity baseDtoToEntity\\(.*BaseVehicleDto dto\\)," - + " .*BaseVehicleEntity anythingToEntity\\(java.lang.Object anyting\\)\\." ), - @Diagnostic( type = Erroneous1Mapper.class, + + " .*BaseVehicleEntity anythingToEntity\\(java.lang.Object anyting\\)\\."), + @Diagnostic(type = Erroneous1Mapper.class, kind = Kind.WARNING, - line = 43, - messageRegExp = "Unmapped target property: \"primaryKey\"\\." ) + line = 42, + messageRegExp = "Unmapped target property: \"primaryKey\"\\.") } ) public void erroneous1MultiplePrototypeMethodsMatch() { @@ -196,18 +197,18 @@ public class InheritFromConfigTest { } @Test - @WithClasses( { Erroneous2Mapper.class } ) + @WithClasses({ Erroneous2Mapper.class }) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic( type = Erroneous2Mapper.class, + @Diagnostic(type = Erroneous2Mapper.class, kind = Kind.ERROR, - line = 39, + line = 38, messageRegExp = "Cycle detected while evaluating inherited configurations. Inheritance path:" + " .*CarEntity toCarEntity1\\(.*CarDto carDto\\)" + " -> .*CarEntity toCarEntity2\\(.*CarDto carDto\\)" + " -> void toCarEntity3\\(.*CarDto carDto, @MappingTarget .*CarEntity entity\\)" - + " -> .*CarEntity toCarEntity1\\(.*CarDto carDto\\)" ) + + " -> .*CarEntity toCarEntity1\\(.*CarDto carDto\\)") } ) public void erroneous2InheritanceCycle() {