Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,17 @@

-->
<#-- @ftlvariable name="" type="org.mapstruct.ap.internal.model.Annotation" -->
@<@includeModel object=type/><#if (properties?size > 0) >(<#list properties as property><@includeModel object=property/><#if property_has_next>, </#if></#list>)</#if>
<#switch properties?size>
<#case 0>
@<@includeModel object=type/><#rt>
<#break>
<#case 1>
@<@includeModel object=type/>(<@includeModel object=properties[0]/>)<#rt>
<#break>
<#default>
@<@includeModel object=type/>(
<#list properties as property>
<#nt><@includeModel object=property/><#if property_has_next>,</#if>
</#list>
)<#rt>
</#switch>
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ public void mapperBecomesDeprecatedAndGetsCustomAnnotation() {
}

@ProcessorTest
@WithClasses( { CustomNamedMapper.class, CustomAnnotationWithParamsContainer.class,
CustomAnnotationWithParams.class } )
@WithClasses( {
CustomNamedMapper.class,
CustomAnnotationWithParamsContainer.class,
CustomAnnotationWithParams.class,
CustomClassOnlyAnnotation.class,
CustomMethodOnlyAnnotation.class,
} )
public void annotationWithValue() {
generatedSource.addComparisonToFixtureFor( CustomNamedMapper.class );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Ben Zegveld
*/
@Mapper
@AnnotateWith( CustomClassOnlyAnnotation.class )
@AnnotateWith( value = CustomAnnotationWithParams.class, elements = {
@Element( name = "stringArray", strings = "test" ),
@Element( name = "stringParam", strings = "test" ),
Expand All @@ -35,6 +36,43 @@
@Element( name = "shortArray", shorts = 3 ),
@Element( name = "shortParam", shorts = 1 )
} )
@AnnotateWith( value = CustomAnnotationWithParams.class, elements = {
@Element(name = "stringParam", strings = "single value")
})
public interface CustomNamedMapper {

@AnnotateWith(value = CustomAnnotationWithParams.class, elements = {
@Element(name = "stringParam", strings = "double method value"),
@Element(name = "stringArray", strings = { "first", "second" }),
})
@AnnotateWith(value = CustomAnnotationWithParams.class, elements = {
@Element(name = "stringParam", strings = "single method value")
})
@AnnotateWith( CustomMethodOnlyAnnotation.class )
Target map(Source source);

class Target {
private final String value;

public Target(String value) {
this.value = value;
}

public String getValue() {
return value;
}
}

class Source {
private final String value;

public Source(String value) {
this.value = value;
}

public String getValue() {
return value;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,50 @@
date = "2022-06-06T16:48:18+0200",
comments = "version: , compiler: javac, environment: Java 11.0.12 (Azul Systems, Inc.)"
)
@CustomAnnotationWithParams(stringArray = "test", stringParam = "test", booleanArray = true, booleanParam = true, byteArray = 16, byteParam = 19, charArray = 'd', charParam = 'a', enumArray = AnnotateWithEnum.EXISTING, enumParam = AnnotateWithEnum.EXISTING, doubleArray = 0.3, doubleParam = 1.2, floatArray = 0.300000011920929f, floatParam = 1.2000000476837158f, intArray = 3, intParam = 1, longArray = 3L, longParam = 1L, shortArray = 3, shortParam = 1)
@CustomClassOnlyAnnotation
@CustomAnnotationWithParams(
stringArray = "test",
stringParam = "test",
booleanArray = true,
booleanParam = true,
byteArray = 16,
byteParam = 19,
charArray = 'd',
charParam = 'a',
enumArray = AnnotateWithEnum.EXISTING,
enumParam = AnnotateWithEnum.EXISTING,
doubleArray = 0.3,
doubleParam = 1.2,
floatArray = 0.300000011920929f,
floatParam = 1.2000000476837158f,
intArray = 3,
intParam = 1,
longArray = 3L,
longParam = 1L,
shortArray = 3,
shortParam = 1
)
@CustomAnnotationWithParams(stringParam = "single value")
public class CustomNamedMapperImpl implements CustomNamedMapper {

@CustomAnnotationWithParams(
stringParam = "double method value",
stringArray = { "first", "second" }
)
@CustomAnnotationWithParams(stringParam = "single method value")
@CustomMethodOnlyAnnotation
@Override
public Target map(Source source) {
if ( source == null ) {
return null;
}

String value = null;

value = source.getValue();

Target target = new Target( value );

return target;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
date = "2022-06-06T16:48:23+0200",
comments = "version: , compiler: javac, environment: Java 11.0.12 (Azul Systems, Inc.)"
)
@CustomAnnotationWithParams(stringArray = { "test1", "test2" }, booleanArray = { false, true }, byteArray = { 8, 31 }, charArray = { 'b', 'c' }, doubleArray = { 1.2, 3.4 }, floatArray = { 1.2000000476837158f, 3.4000000953674316f }, intArray = { 12, 34 }, longArray = { 12L, 34L }, shortArray = { 12, 34 }, classArray = { Mapper.class, CustomAnnotationWithParams.class }, stringParam = "required parameter")
@CustomAnnotationWithParams(
stringArray = { "test1", "test2" },
booleanArray = { false, true },
byteArray = { 8, 31 },
charArray = { 'b', 'c' },
doubleArray = { 1.2, 3.4 },
floatArray = { 1.2000000476837158f, 3.4000000953674316f },
intArray = { 12, 34 },
longArray = { 12L, 34L },
shortArray = { 12, 34 },
classArray = { Mapper.class, CustomAnnotationWithParams.class },
stringParam = "required parameter"
)
public class MultipleArrayValuesMapperImpl implements MultipleArrayValuesMapper {
}