convert primitiv to enum class
See original GitHub issueConversionBodyIllegalCodeException: error in static conversion: probably is an incompatibility of signature, the expected input fields do not match with the real ones, checks the configured class.
I want to convert a primitiv short to an enum object.
.add(attribute("anEnum") .value("aShort")) .add(conversion("shortToEnum") .from("aShort").to("anEnum") .type(JMapConversion.Type.DYNAMIC) .body("return com.test.v1.Enum.get(${source});")));
The class has a get() method which returns an Enum.
public enum Enum {
NUMBER(1);
private final int value;
Enum(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static Enum get(short s){
for(Enum e: values()){
if(e.getValue() == s){
return e;
}
}
return null;
}
}
maybe a Bug?
Issue Analytics
- State:
- Created 7 years ago
- Comments:15 (9 by maintainers)
Top Results From Across the Web
How to convert primitive type value to enum ... - Stack Overflow
Enum variable is basically just a number, it doesn't have a label (such as R2 ) attached to it. For example, FlipRotate2dEnum.
Read more >EnumToIntConverter - .NET MAUI Community Toolkit
The EnumToIntConverter is a converter that allows you to convert a standard Enum (extending int) to its underlying primitive int type.
Read more >[Solved]-Enum inheriting from primitive type-C++
Coding example for the question Enum inheriting from primitive type-C++. ... This does not mean inheritance, this selects the enum's underlying type.
Read more >Rusticity: convert an integer to an enum
Converting an integer to an enum in C. In C, the enumeration constants have the type int . Thus, an integer value can...
Read more >How to convert an enum type variable to a string in C++?
Here we will see how to convert some enum type data to a string in C++. There is no such direct function to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok guys, 1.6.1.CR2 released! i’m apologize for my delay
Fixed!
You need to add the Snapshot repository! go to wiki page for this.
Add a star if you like the project! thank you for support! 👍