mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#242 Fixing typo; Formatting
This commit is contained in:
parent
5af39aa4a0
commit
a9a93b97c8
@ -416,12 +416,12 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
// check constants first
|
// check constants first
|
||||||
if ( !mapping.getConstant().isEmpty() ) {
|
if ( !mapping.getConstant().isEmpty() ) {
|
||||||
return getConstantMapping(
|
return getConstantMapping(
|
||||||
mapperReferences,
|
mapperReferences,
|
||||||
methods,
|
methods,
|
||||||
method,
|
method,
|
||||||
"\"" + mapping.getConstant() + "\"",
|
"\"" + mapping.getConstant() + "\"",
|
||||||
targetAccessor,
|
targetAccessor,
|
||||||
dateFormat
|
dateFormat
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,7 +681,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
|
|
||||||
}
|
}
|
||||||
else if ( mappedProperty.getConstant().isEmpty() &&
|
else if ( mappedProperty.getConstant().isEmpty() &&
|
||||||
mappedProperty.getJavaExpression().isEmpty() &&
|
mappedProperty.getJavaExpression().isEmpty() &&
|
||||||
!hasSourceProperty( method, mappedProperty.getSourcePropertyName() ) ) {
|
!hasSourceProperty( method, mappedProperty.getSourcePropertyName() ) ) {
|
||||||
messager.printMessage(
|
messager.printMessage(
|
||||||
Kind.ERROR,
|
Kind.ERROR,
|
||||||
@ -809,8 +809,8 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
assignment = new SetterWrapper( assignment, method.getThrownTypes() );
|
assignment = new SetterWrapper( assignment, method.getThrownTypes() );
|
||||||
if ( !sourceType.isPrimitive() &&
|
if ( !sourceType.isPrimitive() &&
|
||||||
( assignment.getType() == TYPE_CONVERTED ||
|
( assignment.getType() == TYPE_CONVERTED ||
|
||||||
assignment.getType() == TYPE_CONVERTED_MAPPED ||
|
assignment.getType() == TYPE_CONVERTED_MAPPED ||
|
||||||
assignment.getType() == DIRECT && targetType.isPrimitive() ) ) {
|
assignment.getType() == DIRECT && targetType.isPrimitive() ) ) {
|
||||||
// for primitive types null check is not possible at all, but a conversion needs
|
// for primitive types null check is not possible at all, but a conversion needs
|
||||||
// a null check.
|
// a null check.
|
||||||
assignment = new NullCheckWrapper( assignment );
|
assignment = new NullCheckWrapper( assignment );
|
||||||
@ -820,7 +820,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
// TargetAccessorType must be ADDER
|
// TargetAccessorType must be ADDER
|
||||||
if ( sourceIsCollection ) {
|
if ( sourceIsCollection ) {
|
||||||
assignment =
|
assignment =
|
||||||
new AdderWrapper( assignment, method.getThrownTypes(), sourceReference, sourceType );
|
new AdderWrapper( assignment, method.getThrownTypes(), sourceReference, sourceType );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Possibly adding null to a target collection. So should be surrounded by an null check.
|
// Possibly adding null to a target collection. So should be surrounded by an null check.
|
||||||
@ -912,7 +912,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
String javaExpression,
|
String javaExpression,
|
||||||
ExecutableElement targetAcessor) {
|
ExecutableElement targetAcessor) {
|
||||||
|
|
||||||
Type targetType = typeFactory.getSingleParameter( targetAcessor ).getType();
|
Type targetType = typeFactory.getSingleParameter( targetAcessor ).getType();
|
||||||
Assignment assignment = AssignmentFactory.createSimple( javaExpression );
|
Assignment assignment = AssignmentFactory.createSimple( javaExpression );
|
||||||
assignment = new SetterWrapper( assignment, method.getThrownTypes() );
|
assignment = new SetterWrapper( assignment, method.getThrownTypes() );
|
||||||
return new PropertyMapping( targetAcessor.getSimpleName().toString(), targetType, assignment );
|
return new PropertyMapping( targetAcessor.getSimpleName().toString(), targetType, assignment );
|
||||||
|
@ -23,6 +23,7 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mapstruct.ap.test.collection.adder.source.SingleElementSource;
|
||||||
import org.mapstruct.ap.test.collection.adder.source.Source;
|
import org.mapstruct.ap.test.collection.adder.source.Source;
|
||||||
import org.mapstruct.ap.test.collection.adder.source.SourceTeeth;
|
import org.mapstruct.ap.test.collection.adder.source.SourceTeeth;
|
||||||
import org.mapstruct.ap.test.collection.adder.target.AdderUsageObserver;
|
import org.mapstruct.ap.test.collection.adder.target.AdderUsageObserver;
|
||||||
@ -35,14 +36,13 @@ import org.mapstruct.ap.test.collection.adder.target.TargetHuman;
|
|||||||
import org.mapstruct.ap.test.collection.adder.target.TargetOnlyGetter;
|
import org.mapstruct.ap.test.collection.adder.target.TargetOnlyGetter;
|
||||||
import org.mapstruct.ap.test.collection.adder.target.TargetViaTargetType;
|
import org.mapstruct.ap.test.collection.adder.target.TargetViaTargetType;
|
||||||
import org.mapstruct.ap.test.collection.adder.target.TargetWithoutSetter;
|
import org.mapstruct.ap.test.collection.adder.target.TargetWithoutSetter;
|
||||||
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
import org.mapstruct.ap.testutil.WithClasses;
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||||
|
|
||||||
import static org.fest.assertions.Assertions.assertThat;
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.mapstruct.ap.test.collection.adder.source.SingleElementSource;
|
|
||||||
import org.mapstruct.ap.testutil.IssueKey;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
@ -227,7 +227,7 @@ public class AdderTest {
|
|||||||
|
|
||||||
@IssueKey("242")
|
@IssueKey("242")
|
||||||
@Test
|
@Test
|
||||||
public void testSingleElemtSource() throws DogException {
|
public void testSingleElementSource() throws DogException {
|
||||||
AdderUsageObserver.setUsed( false );
|
AdderUsageObserver.setUsed( false );
|
||||||
|
|
||||||
SingleElementSource source = new SingleElementSource();
|
SingleElementSource source = new SingleElementSource();
|
||||||
@ -239,5 +239,4 @@ public class AdderTest {
|
|||||||
assertThat( target.getPets().get( 0 ) ).isEqualTo( 2L );
|
assertThat( target.getPets().get( 0 ) ).isEqualTo( 2L );
|
||||||
assertTrue( AdderUsageObserver.isUsed() );
|
assertTrue( AdderUsageObserver.isUsed() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class SingleElementSource {
|
|||||||
return pet;
|
return pet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPet( String pet ) {
|
public void setPet(String pet) {
|
||||||
this.pet = pet;
|
this.pet = pet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user