Using https://immutables.github.io/ I wonder if it is possible to have something like custom immutable abstract class inheriting from a class without a default constructor. In this example a sub of Spring's ApplicationEvent (and also take advantage of builder functionality):
@Value.Immutable
@Value.Style(
privateNoargConstructor = true,
get = {"is*", "get*"},
init = "set*",
passAnnotations = Builder.class)
public abstract class CustomEvent extends ApplicationEvent {
//... I need constructor here!
abstract String getFoo();
}
How would you accomplish this if you have no default constructor on the abstract class?
public abstract class ApplicationEvent extends EventObject {
...
public ApplicationEvent(Object source) {
super(source);
...
}
}
EDIT:
If I create a matching constructor like:
private CustomEvent(Object source) {
super(source);
}
I will get a "generated" ImmutableCustomEvent constructor like this:
private ImmutableCustomEvent() {
this.foo = null;
}
Which makes sense, as it tries to generate a class with all the "properties" necessary, but does not consider the "only available" constructor
EDIT2:
What I expect as a generated constructor
private ImmutableCustomEvent() {
super(null)
this.foo = null;
}
or at least
private ImmutableCustomEvent(Object source) {
super(source)
this.foo = null;
}