Skip to content

convert primitiv to enum class #59

@l-salih

Description

@l-salih

ConversionBodyIllegalCodeException: 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?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions