#1213 General code cleanups:

* #122 Use util methods when possible
* Fix some warnings in Javadoc generation
* Don't use raw classes when not needed
* Add .yml, binding.xjb and .asciidoc files to license check exclusion
This commit is contained in:
Filip Hrisafov 2017-05-24 14:15:46 +02:00 committed by GitHub
parent f2ad90042c
commit 2e09944b19
12 changed files with 34 additions and 36 deletions

View File

@ -30,12 +30,13 @@ public enum NullValueCheckStrategy {
/**
* This option includes a null check. When:
* <p>
* <br>
* <br>
* <ol>
* <li>a source value is directly assigned to a target</li>
* <li>a source value assigned to a target by calling a type conversion on the target first</li>
* </ol>
* <p>
* <br>
* <b>NOTE:</b> mapping methods (generated or hand written) are excluded from this null check. They are intended to
* handle a null source value as 'valid' input.
*

View File

@ -534,6 +534,9 @@
<exclude>.gitignore</exclude>
<exclude>.factorypath</exclude>
<exclude>.checkstyle</exclude>
<exclude>*.yml</exclude>
<exclude>**/*.asciidoc</exclude>
<exclude>**/binding.xjb</exclude>
</excludes>
</configuration>
<executions>

View File

@ -74,7 +74,7 @@ public class BigDecimalToStringConversion extends AbstractNumberToStringConversi
@Override
public List<HelperMethod> getRequiredHelperMethods(ConversionContext conversionContext) {
List<HelperMethod> helpers = new ArrayList();
List<HelperMethod> helpers = new ArrayList<HelperMethod>();
if ( conversionContext.getNumberFormat() != null ) {
helpers.add( new CreateDecimalFormat( conversionContext.getTypeFactory() ) );
}

View File

@ -81,7 +81,7 @@ public class BigIntegerToStringConversion extends AbstractNumberToStringConversi
@Override
public List<HelperMethod> getRequiredHelperMethods(ConversionContext conversionContext) {
List<HelperMethod> helpers = new ArrayList();
List<HelperMethod> helpers = new ArrayList<HelperMethod>();
if ( conversionContext.getNumberFormat() != null ) {
helpers.add( new CreateDecimalFormat( conversionContext.getTypeFactory() ) );
}

View File

@ -27,7 +27,7 @@ import org.mapstruct.ap.internal.model.common.Type;
/**
* Model element that can be used to create a type of {@link Iterable} or {@link java.util.Map}. If an implementation
* type is used and the target type has a constructor with {@link int} as parameter and the source parameter is of
* type is used and the target type has a constructor with {@code int} as parameter and the source parameter is of
* {@link java.util.Collection}, {@link java.util.Map} or {@code Array} type then MapStruct will use that constructor
* with the {@code size} / {@code length} from the source parameter.
*

View File

@ -68,7 +68,7 @@ public class ImplementationType {
}
/**
* @return {@code true} if the underlying type has a constructor for {@link int} {@code initialCapacity}, {@code
* @return {@code true} if the underlying type has a constructor for {@code int} {@code initialCapacity}, {@code
* false} otherwise
*/
public boolean hasInitialCapacityConstructor() {

View File

@ -20,6 +20,7 @@ package org.mapstruct.ap.internal.model.source;
import static org.mapstruct.ap.internal.model.source.PropertyEntry.forSourceReference;
import static org.mapstruct.ap.internal.util.Collections.first;
import static org.mapstruct.ap.internal.util.Collections.last;
import java.util.ArrayList;
import java.util.Arrays;
@ -165,28 +166,23 @@ public class SourceReference {
);
}
else {
int notFoundPropertyIndex;
Type sourceType;
if ( entries.isEmpty() ) {
notFoundPropertyIndex = 0;
sourceType = method.getParameters().get( 0 ).getType();
}
else {
int lastFoundEntryIndex = entries.size() - 1;
notFoundPropertyIndex = lastFoundEntryIndex + 1;
sourceType = entries.get( lastFoundEntryIndex ).getType();
int notFoundPropertyIndex = 0;
Type sourceType = method.getParameters().get( 0 ).getType();
if ( !entries.isEmpty() ) {
notFoundPropertyIndex = entries.size();
sourceType = last( entries ).getType();
}
String mostSimilarWord = Strings.getMostSimilarWord(
sourcePropertyNames[notFoundPropertyIndex],
sourceType.getPropertyReadAccessors().keySet()
);
String prefix = "";
for ( int i = 0; i < notFoundPropertyIndex; i++ ) {
prefix += sourcePropertyNames[i] + ".";
}
List<String> elements = new ArrayList<String>(
Arrays.asList( sourcePropertyNames ).subList( 0, notFoundPropertyIndex )
);
elements.add( mostSimilarWord );
reportMappingError(
Message.PROPERTYMAPPING_INVALID_PROPERTY_NAME, mapping.getSourceName(),
prefix + mostSimilarWord
Strings.join( elements, "." )
);
}
isValid = false;

View File

@ -411,12 +411,10 @@ public class TargetReference {
readAccessors
);
String prefix = "";
for ( int i = 0; i < index; i++ ) {
prefix += entryNames[i] + ".";
}
List<String> elements = new ArrayList<String>( Arrays.asList( entryNames ).subList( 0, index ) );
elements.add( mostSimilarProperty );
printErrorMessage( Message.BEANMAPPING_UNKNOWN_PROPERTY_IN_RESULTTYPE, prefix + mostSimilarProperty );
printErrorMessage( Message.BEANMAPPING_UNKNOWN_PROPERTY_IN_RESULTTYPE, Strings.join( elements, "." ) );
}
}

View File

@ -42,7 +42,7 @@ public abstract class BeanMapper {
}
JAXBElement<? super BigDecimal> map(BigDecimal value) {
return new JAXBElement( new QName( "test" ), BigDecimal.class, value );
return new JAXBElement<BigDecimal>( new QName( "test" ), BigDecimal.class, value );
}
}

View File

@ -153,7 +153,7 @@ public class WildCardTest {
public void shouldMapBean() {
GoodIdea aGoodIdea = new GoodIdea();
aGoodIdea.setContent( new JAXBElement( new QName( "test" ), BigDecimal.class, BigDecimal.ONE ) );
aGoodIdea.setContent( new JAXBElement<BigDecimal>( new QName( "test" ), BigDecimal.class, BigDecimal.ONE ) );
aGoodIdea.setDescription( BigDecimal.ZERO );
CunningPlan aCunningPlan = BeanMapper.STM.transformA( aGoodIdea );