I am running into problems using Lombok when I set an enum in the base class.
I have the following code:
@EqualsAndHashCode
@ToString
@Getter
@AllArgsConstructor
@NoArgsConstructor
public abstract class AdminCommand<T extends AdminCommandType, P> {
T type;
P payload;
}
T is an enum type, P is the payload I want to generate. I want to generate classes based on AdminCommand, there the child classes have their own set types.
I am also using this interface to generate my enum:
public interface AdminCommandType {}
I am trying to extend the Admin class using the following:
@EqualsAndHashCode
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class TestCommand<T extends AdminCommandType, O> extends AdminCommand {
enum TestCommandType implements AdminCommandType {
FOO
}
}
My problem comes when I try to instantiate a version of TestCommand.
TestCommand<TestCommand.TestCommandType, "Any POJO Class"> testCommand
= new TestCommand(TestCommand.TestCommandType.FOO, payload);
I get an error saying that no constructor can be found.
This worked when I made the T based on an enum in the base class, but this fails when I make the T based on an interface. Am I missing something?
CodePudding user response:
Lombok @AllArgsConstructor doesn't call super() so you need to create constructor manually for derived classes