initial version
This commit is contained in:
@ -0,0 +1,26 @@
|
||||
package de.muehlencord.mapstruct.support;
|
||||
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import org.mapstruct.ap.spi.DefaultAccessorNamingStrategy;
|
||||
|
||||
/**
|
||||
* MapStruct naming strategy to to support fluent API withXYZ setters. When this strategy is applied, the wither are
|
||||
* ignored so just the normal setter are used.
|
||||
*
|
||||
* @author Joern Muehlencord, 2021-05-01
|
||||
* @since 1.4.2
|
||||
*/
|
||||
public class WitherAccessorNamingStrategy extends DefaultAccessorNamingStrategy {
|
||||
|
||||
@Override
|
||||
protected boolean isFluentSetter(ExecutableElement method) {
|
||||
return !isWitherMethod(method) && super.isFluentSetter(method);
|
||||
}
|
||||
|
||||
protected boolean isWitherMethod(ExecutableElement method) {
|
||||
String methodName = method.getSimpleName().toString();
|
||||
return methodName.length() > 4 && methodName.startsWith("with") && Character.isUpperCase(methodName.charAt(4));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
de.muehlencord.mapstruct.support.WitherAccessorNamingStrategy
|
||||
Reference in New Issue
Block a user