Skip to content

Compilation error "@ProtoAdapter can only be applied to classes" on enum #181

Open
@poschi3

Description

Hi, I wrote a ProtoAdapter for an Enum and get a compilation error:

[ERROR] /home/user/.../caching/src/main/java/com/example/ColorEnumAdapter.java:[7,8] @ProtoAdapter can only be applied to classes.

But documentation says

@ProtoAdapter is a marshalling adapter for a class or enum that you cannot annotate directly.

I also found an Unit Test in source code doing this. My example files are adopted from there:

ColorEnum.java

package com.example;

public enum ColorEnum {
    RED, GREEN, BLUE
}

ColorEnumAdapter.java

package com.example;

import org.infinispan.protostream.annotations.ProtoAdapter;
import org.infinispan.protostream.annotations.ProtoEnumValue;

@ProtoAdapter(ColorEnum.class)
public enum ColorEnumAdapter {

    @ProtoEnumValue(number = 0, name = "red")
    RED,

    @ProtoEnumValue(number = 1, name = "green")
    GREEN,

    @ProtoEnumValue(number = 2, name = "blue")
    BLUE
}

Can you help me to find out what I'm doing wrong?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions