-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When performing a conversion from an enum to the same enum, the AnyToEnumConverter is triggered, which performs a full cycle conversion, using the toString() method of source and the valueOf() of the target enum. When the source enum is the same as the target enum and the source enum has an overridden toString() method, this fails because the value can not be mapped to the enum. Instead, the AnyToEnumConverter now checks whether the source is of the same enum class as the target. If this is the case, the conversion task is skipped and the source is returned literally.
- Loading branch information
1 parent
1e2ee76
commit 65a9628
Showing
5 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/test/java/io/beanmapper/testmodel/enums/EnumWithToString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.beanmapper.testmodel.enums; | ||
|
||
public enum EnumWithToString { | ||
SOME_VALUE; | ||
|
||
public String toString() { | ||
return "X" + name() + "X"; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/test/java/io/beanmapper/testmodel/enums/SourceWithEnumWithToString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.beanmapper.testmodel.enums; | ||
|
||
public class SourceWithEnumWithToString { | ||
public EnumWithToString myEnum; | ||
} |
5 changes: 5 additions & 0 deletions
5
src/test/java/io/beanmapper/testmodel/enums/TargetWithEnumWithToString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.beanmapper.testmodel.enums; | ||
|
||
public class TargetWithEnumWithToString { | ||
public EnumWithToString myEnum; | ||
} |