mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#203 Move .ftl files into subdirectories representing the package path
This commit is contained in:
parent
1baf8edc0a
commit
c8e9f91037
@ -152,6 +152,6 @@ public class Decorator extends GeneratedType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTemplateName() {
|
protected String getTemplateName() {
|
||||||
return GeneratedType.class.getName() + ".ftl";
|
return getTemplateNameForClass( GeneratedType.class );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,6 @@ public class Mapper extends GeneratedType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTemplateName() {
|
protected String getTemplateName() {
|
||||||
return GeneratedType.class.getName() + ".ftl";
|
return getTemplateNameForClass( GeneratedType.class );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,15 +31,13 @@ import org.mapstruct.ap.internal.model.source.builtin.BuiltInMethod;
|
|||||||
*/
|
*/
|
||||||
public class VirtualMappingMethod extends MappingMethod {
|
public class VirtualMappingMethod extends MappingMethod {
|
||||||
|
|
||||||
private static final String BUILTIN_METHOD_TEMPLATE_PREFIX = "org.mapstruct.ap.internal.model.builtin.";
|
|
||||||
|
|
||||||
private final String templateName;
|
private final String templateName;
|
||||||
private final Set<Type> importTypes;
|
private final Set<Type> importTypes;
|
||||||
|
|
||||||
public VirtualMappingMethod(BuiltInMethod method) {
|
public VirtualMappingMethod(BuiltInMethod method) {
|
||||||
super( method );
|
super( method );
|
||||||
this.importTypes = method.getImportTypes();
|
this.importTypes = method.getImportTypes();
|
||||||
this.templateName = BUILTIN_METHOD_TEMPLATE_PREFIX + method.getClass().getSimpleName() + ".ftl";
|
this.templateName = getTemplateNameForClass( method.getClass() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,13 +33,24 @@ public abstract class FreeMarkerWritable implements Writable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the template to be used for a specific writable type. By default, the fully-qualified class
|
* Returns the name of the template to be used for a specific writable type. By default,
|
||||||
* name of the given model element type, appended with the extension {@code *.ftl} is used as template file name,
|
* {@link #getTemplateNameForClass(Class)} is called with {@code getClass()}, but this can be customized by
|
||||||
* but this can be customized by overriding this method if required.
|
* overriding this method if required.
|
||||||
*
|
*
|
||||||
* @return the name of the template. Must not be {@code null}.
|
* @return the name of the template. Must not be {@code null}.
|
||||||
*/
|
*/
|
||||||
protected String getTemplateName() {
|
protected String getTemplateName() {
|
||||||
return getClass().getName() + ".ftl";
|
return getTemplateNameForClass( getClass() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the template to be used for a specific writable type. By default, the package directory and
|
||||||
|
* the class name of the given model element type, appended with the extension {@code *.ftl} is used as template
|
||||||
|
* file name.
|
||||||
|
*
|
||||||
|
* @return the name of the template. Must not be {@code null}.
|
||||||
|
*/
|
||||||
|
protected String getTemplateNameForClass(Class<?> clazz) {
|
||||||
|
return clazz.getName().replace( '.', '/' ) + ".ftl";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user