mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#295 Formatting
This commit is contained in:
parent
4ca2b6ecf1
commit
2fde97c039
@ -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 NullValueMapping {
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
@ -40,8 +39,8 @@ import org.mapstruct.ap.model.source.Mapping;
|
||||
import org.mapstruct.ap.model.source.SourceMethod;
|
||||
import org.mapstruct.ap.model.source.SourceReference;
|
||||
import org.mapstruct.ap.option.ReportingPolicy;
|
||||
import org.mapstruct.ap.prism.NullValueMappingPrism;
|
||||
import org.mapstruct.ap.prism.CollectionMappingStrategyPrism;
|
||||
import org.mapstruct.ap.prism.NullValueMappingPrism;
|
||||
import org.mapstruct.ap.util.Executables;
|
||||
import org.mapstruct.ap.util.MapperConfig;
|
||||
import org.mapstruct.ap.util.Strings;
|
||||
@ -183,7 +182,8 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
if ( targetProperty == null ) {
|
||||
ctx.getMessager().printMessage(
|
||||
Diagnostic.Kind.ERROR,
|
||||
String.format( "Unknown property \"%s\" in return type.",
|
||||
String.format(
|
||||
"Unknown property \"%s\" in return type.",
|
||||
mapping.getTargetName()
|
||||
),
|
||||
method.getExecutable(),
|
||||
@ -456,8 +456,7 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void reportErrorForUnmappedTargetPropertiesIfRequired( ) {
|
||||
private void reportErrorForUnmappedTargetPropertiesIfRequired() {
|
||||
|
||||
// fetch settings from element to implement
|
||||
ReportingPolicy unmappedTargetPolicy = getEffectiveUnmappedTargetPolicy();
|
||||
@ -480,7 +479,7 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
private BeanMappingMethod(SourceMethod method,
|
||||
List<PropertyMapping> propertyMappings,
|
||||
MethodReference factoryMethod,
|
||||
boolean mapNullToDefault ) {
|
||||
boolean mapNullToDefault) {
|
||||
super( method );
|
||||
this.propertyMappings = propertyMappings;
|
||||
|
||||
@ -532,7 +531,7 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
public List<Parameter> getSourceParametersExcludingPrimitives() {
|
||||
List<Parameter> sourceParameters = new ArrayList<Parameter>();
|
||||
for ( Parameter sourceParam : getSourceParameters() ) {
|
||||
if (!sourceParam.getType().isPrimitive()) {
|
||||
if ( !sourceParam.getType().isPrimitive() ) {
|
||||
sourceParameters.add( sourceParam );
|
||||
}
|
||||
}
|
||||
@ -543,7 +542,7 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
public List<Parameter> getSourcePrimitiveParameters() {
|
||||
List<Parameter> sourceParameters = new ArrayList<Parameter>();
|
||||
for ( Parameter sourceParam : getSourceParameters() ) {
|
||||
if (sourceParam.getType().isPrimitive()) {
|
||||
if ( sourceParam.getType().isPrimitive() ) {
|
||||
sourceParameters.add( sourceParam );
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ package org.mapstruct.ap.model;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
@ -126,7 +125,7 @@ public class IterableMappingMethod extends MappingMethod {
|
||||
|
||||
|
||||
private IterableMappingMethod(Method method, Assignment parameterAssignment, MethodReference factoryMethod,
|
||||
boolean mapNullToDefault, TypeFactory typeFactory ) {
|
||||
boolean mapNullToDefault, TypeFactory typeFactory) {
|
||||
super( method );
|
||||
this.elementAssignment = parameterAssignment;
|
||||
this.factoryMethod = factoryMethod;
|
||||
@ -157,7 +156,7 @@ public class IterableMappingMethod extends MappingMethod {
|
||||
types.addAll( elementAssignment.getImportTypes() );
|
||||
}
|
||||
|
||||
if (mapNullToDefault) {
|
||||
if ( mapNullToDefault ) {
|
||||
types.add( typeFactory.getType( Collections.class ) );
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ package org.mapstruct.ap.model;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
@ -202,7 +201,7 @@ public class MapMappingMethod extends MappingMethod {
|
||||
types.addAll( valueAssignment.getImportTypes() );
|
||||
}
|
||||
|
||||
if (mapNullToDefault) {
|
||||
if ( mapNullToDefault ) {
|
||||
types.add( typeFactory.getType( Collections.class ) );
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ public class PropertyMapping extends ModelElement {
|
||||
}
|
||||
|
||||
private Assignment assignObject(Type sourceType, Type targetType, TargetAccessorType targetAccessorType,
|
||||
Assignment rhs ) {
|
||||
Assignment rhs) {
|
||||
|
||||
Assignment result = rhs;
|
||||
|
||||
@ -217,7 +217,7 @@ public class PropertyMapping extends ModelElement {
|
||||
|
||||
}
|
||||
|
||||
private Assignment assignCollection( Type targetType, TargetAccessorType targetAccessorType, Assignment rhs ) {
|
||||
private Assignment assignCollection(Type targetType, TargetAccessorType targetAccessorType, Assignment rhs) {
|
||||
|
||||
Assignment result = rhs;
|
||||
|
||||
|
@ -22,17 +22,16 @@ import javax.xml.bind.annotation.XmlElementDecl;
|
||||
|
||||
import net.java.dev.hickory.prism.GeneratePrism;
|
||||
import net.java.dev.hickory.prism.GeneratePrisms;
|
||||
|
||||
import org.mapstruct.DecoratedWith;
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.IterableMapping;
|
||||
import org.mapstruct.MapMapping;
|
||||
import org.mapstruct.NullValueMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MapperConfig;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.NullValueMapping;
|
||||
import org.mapstruct.Qualifier;
|
||||
import org.mapstruct.TargetType;
|
||||
|
||||
@ -52,8 +51,8 @@ import org.mapstruct.TargetType;
|
||||
@GeneratePrism(value = DecoratedWith.class, publicAccess = true),
|
||||
@GeneratePrism(value = MapperConfig.class, publicAccess = true),
|
||||
@GeneratePrism(value = InheritInverseConfiguration.class, publicAccess = true),
|
||||
@GeneratePrism( value = Qualifier.class, publicAccess = true ),
|
||||
@GeneratePrism( value = NullValueMapping.class, publicAccess = true ),
|
||||
@GeneratePrism(value = Qualifier.class, publicAccess = true),
|
||||
@GeneratePrism(value = NullValueMapping.class, publicAccess = true),
|
||||
|
||||
// external types
|
||||
@GeneratePrism(value = XmlElementDecl.class, publicAccess = true)
|
||||
|
@ -22,20 +22,18 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.type.DeclaredType;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
import org.mapstruct.ap.prism.NullValueMappingStrategyPrism;
|
||||
import org.mapstruct.ap.prism.NullValueMappingPrism;
|
||||
|
||||
import org.mapstruct.ap.option.ReportingPolicy;
|
||||
import org.mapstruct.ap.prism.CollectionMappingStrategyPrism;
|
||||
import org.mapstruct.ap.prism.MapperConfigPrism;
|
||||
import org.mapstruct.ap.prism.MapperPrism;
|
||||
import org.mapstruct.ap.prism.NullValueMappingPrism;
|
||||
import org.mapstruct.ap.prism.NullValueMappingStrategyPrism;
|
||||
|
||||
import static org.mapstruct.ap.prism.CollectionMappingStrategyPrism.valueOf;
|
||||
|
||||
|
@ -18,8 +18,6 @@
|
||||
*/
|
||||
package org.mapstruct.ap.test.mapnulltodefault;
|
||||
|
||||
import static org.mapstruct.NullValueMappingStrategy.RETURN_DEFAULT;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -32,6 +30,8 @@ import org.mapstruct.ap.test.mapnulltodefault.source.Car;
|
||||
import org.mapstruct.ap.test.mapnulltodefault.target.CarDto;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import static org.mapstruct.NullValueMappingStrategy.RETURN_DEFAULT;
|
||||
|
||||
@Mapper(imports = UUID.class)
|
||||
public interface CarMapper {
|
||||
|
||||
|
@ -23,15 +23,15 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.NullValueMapping;
|
||||
import org.mapstruct.NullValueMappingStrategy;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.NullValueMapping;
|
||||
import org.mapstruct.NullValueMappingStrategy;
|
||||
import org.mapstruct.ap.test.mapnulltodefault.source.Car;
|
||||
import org.mapstruct.ap.test.mapnulltodefault.target.CarDto;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper(imports = UUID.class, config = CentralConfig.class )
|
||||
@Mapper(imports = UUID.class, config = CentralConfig.class)
|
||||
public interface CarMapperSettingOnConfig {
|
||||
|
||||
CarMapperSettingOnConfig INSTANCE = Mappers.getMapper( CarMapperSettingOnConfig.class );
|
||||
|
@ -23,15 +23,15 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.NullValueMapping;
|
||||
import org.mapstruct.NullValueMappingStrategy;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.NullValueMapping;
|
||||
import org.mapstruct.NullValueMappingStrategy;
|
||||
import org.mapstruct.ap.test.mapnulltodefault.source.Car;
|
||||
import org.mapstruct.ap.test.mapnulltodefault.target.CarDto;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper(imports = UUID.class, nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT )
|
||||
@Mapper(imports = UUID.class, nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
|
||||
public interface CarMapperSettingOnMapper {
|
||||
|
||||
CarMapperSettingOnMapper INSTANCE = Mappers.getMapper( CarMapperSettingOnMapper.class );
|
||||
|
@ -22,8 +22,6 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static org.fest.assertions.Assertions.assertThat;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -32,6 +30,8 @@ import org.mapstruct.ap.test.mapnulltodefault.target.CarDto;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
|
||||
import static org.fest.assertions.Assertions.assertThat;
|
||||
|
||||
@WithClasses({
|
||||
Car.class,
|
||||
CarDto.class,
|
||||
@ -122,13 +122,13 @@ public class CarMapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings( { "rawtypes", "unchecked" } )
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void shouldMapMapWithNullArg() {
|
||||
|
||||
//given
|
||||
Car car = new Car( "Morris", 2 );
|
||||
Map carMap = new HashMap();
|
||||
carMap.put( 1, car);
|
||||
carMap.put( 1, car );
|
||||
|
||||
//when
|
||||
Map<Integer, CarDto> carDtoMap1 = CarMapper.INSTANCE.carsToCarDtoMap( carMap );
|
||||
|
@ -18,14 +18,13 @@
|
||||
*/
|
||||
package org.mapstruct.ap.test.mapnulltodefault;
|
||||
|
||||
import org.mapstruct.NullValueMappingStrategy;
|
||||
import org.mapstruct.MapperConfig;
|
||||
import org.mapstruct.NullValueMappingStrategy;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
@MapperConfig( nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT )
|
||||
@MapperConfig(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
|
||||
public class CentralConfig {
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class CarDto {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel( String model ) {
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public class CarDto {
|
||||
return catalogId;
|
||||
}
|
||||
|
||||
public void setCatalogId( String catalogId ) {
|
||||
public void setCatalogId(String catalogId) {
|
||||
this.catalogId = catalogId;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user