mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#1 Simplifying enum conversion
This commit is contained in:
parent
74e673945f
commit
fcbbd73cda
@ -24,11 +24,11 @@ public class EnumStringConversion implements Conversion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String to(String sourcePropertyAccessor, Type type) {
|
public String to(String sourcePropertyAccessor, Type type) {
|
||||||
return sourcePropertyAccessor + " != null ? " + sourcePropertyAccessor + ".toString() : null";
|
return sourcePropertyAccessor + ".toString()";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String from(String targetPropertyAccessor, Type type) {
|
public String from(String targetPropertyAccessor, Type type) {
|
||||||
return targetPropertyAccessor + " != null ? Enum.valueOf( " + type.getName() + ".class, " + targetPropertyAccessor + " ) : null";
|
return "Enum.valueOf( " + type.getName() + ".class, " + targetPropertyAccessor + " )";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user