mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#1675 Making MapStruct compileable with OpenJDK 11
This commit is contained in:
parent
98d86cee84
commit
ae3758674a
@ -86,4 +86,21 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jdk-11-or-newer</id>
|
||||
<activation>
|
||||
<jdk>[11</jdk>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
@ -304,4 +304,20 @@
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jdk-11-or-newer</id>
|
||||
<activation>
|
||||
<jdk>[11</jdk>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
@ -12,9 +12,9 @@ import org.mapstruct.ap.internal.model.common.Type;
|
||||
import org.mapstruct.ap.internal.util.Collections;
|
||||
|
||||
/**
|
||||
* Handles conversion between a target type <tt>T</tt> and {@link String},
|
||||
* Handles conversion between a target type {@code T} and {@link String},
|
||||
* where {@code T#parse(String)} and {@code T#toString} are inverse operations.
|
||||
* The {@link ConversionContext#getTargetType()} is used as the from target type <tt>T</tt>.
|
||||
* The {@link ConversionContext#getTargetType()} is used as the from target type {@code T}.
|
||||
*/
|
||||
public class StaticParseToStringConversion extends SimpleConversion {
|
||||
|
||||
|
@ -28,7 +28,8 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
Identifiable.class,
|
||||
HasId.class,
|
||||
AlsoHasId.class,
|
||||
Measurable.class
|
||||
Measurable.class,
|
||||
Holder.class
|
||||
})
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
public class AbstractClassTest {
|
||||
|
@ -5,12 +5,11 @@
|
||||
*/
|
||||
package org.mapstruct.ap.test.abstractclass;
|
||||
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
/**
|
||||
* @author Andreas Gudian
|
||||
*/
|
||||
public abstract class AbstractReferencedMapper implements ReferencedMapperInterface {
|
||||
|
||||
@Override
|
||||
public int holderToInt(Holder<String> holder) {
|
||||
return 41;
|
||||
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.abstractclass;
|
||||
|
||||
/**
|
||||
* @author Gunnar Morling
|
||||
*/
|
||||
public class Holder<T> {
|
||||
|
||||
public Holder(String string) {
|
||||
}
|
||||
}
|
@ -5,12 +5,11 @@
|
||||
*/
|
||||
package org.mapstruct.ap.test.abstractclass;
|
||||
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
/**
|
||||
* @author Andreas Gudian
|
||||
*/
|
||||
public class ReferencedMapper extends AbstractReferencedMapper {
|
||||
|
||||
@Override
|
||||
public int holderToInt(Holder<String> holder) {
|
||||
return 42;
|
||||
|
@ -5,11 +5,10 @@
|
||||
*/
|
||||
package org.mapstruct.ap.test.abstractclass;
|
||||
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
/**
|
||||
* @author Andreas Gudian
|
||||
*/
|
||||
public interface ReferencedMapperInterface {
|
||||
|
||||
int holderToInt(Holder<String> holder);
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ package org.mapstruct.ap.test.abstractclass;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
public class Source extends AbstractDto implements HasId, AlsoHasId {
|
||||
|
||||
//CHECKSTYLE:OFF
|
||||
|
@ -9,6 +9,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.assertj.core.api.ListAssert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mapstruct.ap.test.bugs._1170._target.Target;
|
||||
@ -44,8 +45,8 @@ public class AdderTest {
|
||||
assertThat( target ).isNotNull();
|
||||
assertThat( target.getWithoutWildcards() ).containsExactly( 2L );
|
||||
assertThat( target.getWildcardInSources() ).containsExactly( 2L );
|
||||
assertThat( target.getWildcardInTargets() ).containsExactly( 2L );
|
||||
assertThat( target.getWildcardInBoths() ).containsExactly( 2L );
|
||||
( (ListAssert<Long>) assertThat( target.getWildcardInTargets() ) ).containsExactly( 2L );
|
||||
( (ListAssert<Long>) assertThat( target.getWildcardInBoths() ) ).containsExactly( 2L );
|
||||
assertThat( target.getWildcardAdderToSetters() ).containsExactly( 2L );
|
||||
}
|
||||
|
||||
@ -63,10 +64,9 @@ public class AdderTest {
|
||||
|
||||
assertThat( source ).isNotNull();
|
||||
assertThat( source.getWithoutWildcards() ).containsExactly( "mouse" );
|
||||
assertThat( source.getWildcardInSources() ).containsExactly( "mouse" );
|
||||
( (ListAssert<String>) assertThat( source.getWildcardInSources() ) ).containsExactly( "mouse" );
|
||||
assertThat( source.getWildcardInTargets() ).containsExactly( "mouse" );
|
||||
assertThat( source.getWildcardInBoths() ).containsExactly( "mouse" );
|
||||
assertThat( source.getWildcardAdderToSetters() ).containsExactly( "mouse" );
|
||||
( (ListAssert<String>) assertThat( source.getWildcardInBoths() ) ).containsExactly( "mouse" );
|
||||
( (ListAssert<String>) assertThat( source.getWildcardAdderToSetters() ) ).containsExactly( "mouse" );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.assertj.core.api.IterableAssert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
@ -42,7 +43,8 @@ public class IterableWithBoundedElementTypeTest {
|
||||
source.setValues( Arrays.asList( "42", "47" ) );
|
||||
IterableContainer result = MapperWithForgedIterableMapping.INSTANCE.toContainerWithIterable( source );
|
||||
|
||||
assertThat( result.getValues() ).contains( Integer.valueOf( 42 ), Integer.valueOf( 47 ) );
|
||||
( (IterableAssert<Integer>) assertThat( result.getValues() ) )
|
||||
.contains( Integer.valueOf( 42 ), Integer.valueOf( 47 ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -52,6 +54,7 @@ public class IterableWithBoundedElementTypeTest {
|
||||
source.setValues( Arrays.asList( "42", "47" ) );
|
||||
IterableContainer result = MapperWithCustomListMapping.INSTANCE.toContainerWithIterable( source );
|
||||
|
||||
assertThat( result.getValues() ).contains( Integer.valueOf( 66 ), Integer.valueOf( 71 ) );
|
||||
( (IterableAssert<Integer>) assertThat( result.getValues() ) )
|
||||
.contains( Integer.valueOf( 66 ), Integer.valueOf( 71 ) );
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user