Skip to content

IllegalArgumentException during mapping an enum with the abstract method #152

Closed
@Dreando

Description

@Dreando

If you wanna map the enum which contains an abstract method :

Map<String, ?> conversionResult = beanMapper.map(convertedBean, Map.class);

where the bean is:

public class ConvertedBean {

    private ConvertedEnum enum;

    // getters & setters
}

and the enum is:

public enum ConvertedEnum {

        SUCCESSFUL {
        @Override
        public boolean isOverallStatus(Set<SomeType> stats) {
            return EnumSet.of(SomeType.SUCCESSFUL, SomeType.EXCLUDED).containsAll(stats);
        }
    };

    public abstract boolean isOverallStatus(Set<SomeType> stats);
}

And when we want to map it, this causes:

java.lang.IllegalArgumentException: package.ConvertedEnum$1 is not an enum type.

Probably the reason is that in some place after getClass() invocation should be use also getDeclaringType() method.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions