Skip to content

Commit fd286e1

Browse files
committed
mapstruct#33 Fixing CheckStyle issues
1 parent 42ac8f3 commit fd286e1

28 files changed

Lines changed: 103 additions & 54 deletions

File tree

core/src/main/java/org/mapstruct/Mappers.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
*/
2626
public class Mappers {
2727

28-
private final static String IMPLEMENTATION_SUFFIX = "Impl";
28+
private static final String IMPLEMENTATION_SUFFIX = "Impl";
29+
30+
private Mappers() {
31+
}
2932

3033
/**
3134
* Returns an instance of the given mapper type.

core/src/test/java/org/mapstruct/MappersTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818
*/
1919
package org.mapstruct;
2020

21-
2221
import org.mapstruct.test.model.Foo;
2322
import org.testng.annotations.Test;
2423

2524
import static org.fest.assertions.Assertions.assertThat;
2625

26+
/**
27+
* Unit test for {@link Mappers}.
28+
*
29+
* @author Gunnar Morling
30+
*/
2731
public class MappersTest {
2832

2933
@Test

integrationtest/src/main/java/org/mapstruct/itest/SourceTargetMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
@Mapper
2727
public interface SourceTargetMapper {
2828

29-
public static SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
29+
SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
3030

3131
@Mappings({
3232
@Mapping(source = "qax", target = "baz"),

processor/src/main/java/org/mapstruct/ap/MapperGenerationVisitor.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
public class MapperGenerationVisitor extends ElementKindVisitor6<Void, Void> {
6464

65-
private final static String IMPLEMENTATION_SUFFIX = "Impl";
65+
private static final String IMPLEMENTATION_SUFFIX = "Impl";
6666

6767
private final ProcessingEnvironment processingEnvironment;
6868
private final Types typeUtils;
@@ -235,7 +235,9 @@ private List<BeanMapping> getMappings(List<Method> methods) {
235235
return mappings;
236236
}
237237

238-
private void reportErrorIfPropertyCanNotBeMapped(Method method, Method reverseMethod, MappedProperty property, Method propertyMappingMethod, Method reversePropertyMappingMethod, Conversion conversion) {
238+
private void reportErrorIfPropertyCanNotBeMapped(Method method, Method reverseMethod, MappedProperty property,
239+
Method propertyMappingMethod, Method reversePropertyMappingMethod,
240+
Conversion conversion) {
239241
if ( property.getSourceType().equals( property.getTargetType() ) ) {
240242
return;
241243
}
@@ -282,7 +284,8 @@ private void reportErrorIfPropertyCanNotBeMapped(Method method, Method reverseMe
282284
}
283285
}
284286

285-
private String getIterableConversionString(Conversions conversions, Type sourceElementType, Type targetElementType, boolean isToConversion) {
287+
private String getIterableConversionString(Conversions conversions, Type sourceElementType, Type targetElementType,
288+
boolean isToConversion) {
286289
Conversion conversion = conversions.getConversion( sourceElementType, targetElementType );
287290

288291
if ( conversion == null ) {
@@ -435,7 +438,8 @@ private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<S
435438
String sourcePropertyName = Executables.getPropertyName( getterMethod );
436439
Mapping mapping = mappings.get( sourcePropertyName );
437440

438-
for ( ExecutableElement setterMethod : Filters.setterMethodsIn( returnTypeElement.getEnclosedElements() ) ) {
441+
for ( ExecutableElement setterMethod :Filters.setterMethodsIn( returnTypeElement
442+
.getEnclosedElements() ) ) {
439443

440444
String targetPropertyName = Executables.getPropertyName( setterMethod );
441445

processor/src/main/java/org/mapstruct/ap/conversion/PrimitiveToStringConversion.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public String to(String sourcePropertyAccessor, Type type) {
4343

4444
@Override
4545
public String from(String targetPropertyAccessor, Type type) {
46-
return wrapperType.getSimpleName() + ".parse" + Strings.capitalize( sourceType.getSimpleName() ) + "( " + targetPropertyAccessor + " )";
46+
return wrapperType.getSimpleName() + ".parse" + Strings.capitalize( sourceType.getSimpleName() ) + "( " +
47+
targetPropertyAccessor + " )";
4748
}
4849
}

processor/src/main/java/org/mapstruct/ap/conversion/WrapperToStringConversion.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public String to(String sourcePropertyAccessor, Type type) {
4343

4444
@Override
4545
public String from(String targetPropertyAccessor, Type type) {
46-
return sourceType.getSimpleName() + ".parse" + Strings.capitalize( primitiveType.getSimpleName() ) + "( " + targetPropertyAccessor + " )";
46+
return sourceType.getSimpleName() + ".parse" + Strings.capitalize( primitiveType.getSimpleName() ) + "( " +
47+
targetPropertyAccessor + " )";
4748
}
4849
}

processor/src/main/java/org/mapstruct/ap/model/BeanMapping.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public class BeanMapping {
3131
private final String toConversion;
3232
private final String fromConversion;
3333

34-
public BeanMapping(Type sourceType, Type targetType, List<PropertyMapping> propertyMappings, MappingMethod mappingMethod,
34+
public BeanMapping(Type sourceType, Type targetType, List<PropertyMapping> propertyMappings,
35+
MappingMethod mappingMethod,
3536
MappingMethod reverseMappingMethod, String toConversion, String fromConversion) {
3637
this.sourceType = sourceType;
3738
this.targetType = targetType;

processor/src/main/java/org/mapstruct/ap/model/Mapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public class Mapper {
3535
private final SortedSet<Type> importedTypes;
3636

3737
public Mapper(String packageName, String interfaceName,
38-
String implementationName, List<BeanMapping> beanMappings, List<Type> usedMapperTypes, Options options) {
38+
String implementationName, List<BeanMapping> beanMappings, List<Type> usedMapperTypes,
39+
Options options) {
3940
this.packageName = packageName;
4041
this.interfaceName = interfaceName;
4142
this.implementationName = implementationName;

processor/src/main/java/org/mapstruct/ap/model/PropertyMapping.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public class PropertyMapping {
4040
private final String toConversion;
4141
private final String fromConversion;
4242

43-
public PropertyMapping(String sourceReadAccessorName, String sourceWriteAccessorName, Type sourceType, String targetReadAccessorName, String targetWriteAccessorName, Type targetType, MappingMethod mappingMethod, MappingMethod reverseMappingMethod, String toConversion, String fromConversion) {
43+
public PropertyMapping(String sourceReadAccessorName, String sourceWriteAccessorName, Type sourceType,
44+
String targetReadAccessorName, String targetWriteAccessorName, Type targetType,
45+
MappingMethod mappingMethod, MappingMethod reverseMappingMethod, String toConversion,
46+
String fromConversion) {
4447
this.sourceReadAccessorName = sourceReadAccessorName;
4548
this.sourceWriteAccessorName = sourceWriteAccessorName;
4649
this.sourceType = sourceType;

processor/src/main/java/org/mapstruct/ap/model/Type.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,22 @@
3434
*/
3535
public class Type implements Comparable<Type> {
3636

37-
private final static Set<String> primitiveTypeNames = new HashSet<String>(
37+
private static final Set<String> PRIMITIVE_TYPE_NAMES = new HashSet<String>(
3838
Arrays.asList( "boolean", "char", "byte", "short", "int", "long", "float", "double" )
3939
);
4040

41-
private final static ConcurrentMap<String, Type> defaultIterableImplementationTypes = new ConcurrentHashMap<String, Type>();
42-
private final static ConcurrentMap<String, Type> defaultCollectionImplementationTypes = new ConcurrentHashMap<String, Type>();
41+
private static final ConcurrentMap<String, Type> DEFAULT_ITERABLE_IMPLEMENTATION_TYPES =
42+
new ConcurrentHashMap<String, Type>();
43+
private static final ConcurrentMap<String, Type> DEFAULT_COLLECTION_IMPLEMENTATION_TYPES =
44+
new ConcurrentHashMap<String, Type>();
4345

4446
static {
45-
defaultCollectionImplementationTypes.put( List.class.getName(), forClass( ArrayList.class ) );
46-
defaultCollectionImplementationTypes.put( Set.class.getName(), forClass( HashSet.class ) );
47-
defaultCollectionImplementationTypes.put( Collection.class.getName(), forClass( ArrayList.class ) );
47+
DEFAULT_COLLECTION_IMPLEMENTATION_TYPES.put( List.class.getName(), forClass( ArrayList.class ) );
48+
DEFAULT_COLLECTION_IMPLEMENTATION_TYPES.put( Set.class.getName(), forClass( HashSet.class ) );
49+
DEFAULT_COLLECTION_IMPLEMENTATION_TYPES.put( Collection.class.getName(), forClass( ArrayList.class ) );
4850

49-
defaultIterableImplementationTypes.put( Iterable.class.getName(), forClass( ArrayList.class ) );
50-
defaultIterableImplementationTypes.putAll( defaultCollectionImplementationTypes );
51+
DEFAULT_ITERABLE_IMPLEMENTATION_TYPES.put( Iterable.class.getName(), forClass( ArrayList.class ) );
52+
DEFAULT_ITERABLE_IMPLEMENTATION_TYPES.putAll( DEFAULT_COLLECTION_IMPLEMENTATION_TYPES );
5153
}
5254

5355
private final String packageName;
@@ -81,7 +83,8 @@ public Type(String name) {
8183
this( null, name, null, false, false, false );
8284
}
8385

84-
public Type(String packageName, String name, Type elementType, boolean isEnumType, boolean isCollectionType, boolean isIterableType) {
86+
public Type(String packageName, String name, Type elementType, boolean isEnumType, boolean isCollectionType,
87+
boolean isIterableType) {
8588
this.packageName = packageName;
8689
this.name = name;
8790
this.elementType = elementType;
@@ -90,14 +93,14 @@ public Type(String packageName, String name, Type elementType, boolean isEnumTyp
9093
this.isIterableType = isIterableType;
9194

9295
if ( isCollectionType ) {
93-
collectionImplementationType = defaultCollectionImplementationTypes.get( packageName + "." + name );
96+
collectionImplementationType = DEFAULT_COLLECTION_IMPLEMENTATION_TYPES.get( packageName + "." + name );
9497
}
9598
else {
9699
collectionImplementationType = null;
97100
}
98101

99102
if ( isIterableType ) {
100-
iterableImplementationType = defaultIterableImplementationTypes.get( packageName + "." + name );
103+
iterableImplementationType = DEFAULT_ITERABLE_IMPLEMENTATION_TYPES.get( packageName + "." + name );
101104
}
102105
else {
103106
iterableImplementationType = null;
@@ -117,7 +120,7 @@ public Type getElementType() {
117120
}
118121

119122
public boolean isPrimitive() {
120-
return packageName == null && primitiveTypeNames.contains( name );
123+
return packageName == null && PRIMITIVE_TYPE_NAMES.contains( name );
121124
}
122125

123126
public boolean isEnumType() {

0 commit comments

Comments
 (0)