Reputation: 722
I have declared a simple enum in Groovy which is perfectly valid in Java. I get an error,
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: AdmixtureProperties(String, Integer, LinkedHashMap)
Here is the enum
@ToString
enum AdmixtureProperties {
SVALUE(prop:"1", num: 1),
PVALUE(prop:"5", num: 3);
private String prop
private int num
AdmixtureProperties(String prop, int num){
this.prop=prop
this.num=num
}
}
Upvotes: 0
Views: 550
Reputation: 187529
I have declared a simple enum in Groovy which is perfectly valid in Java.
This would not be a valid enum in Java for a couple of reasons
SVALUE(prop:"1", num: 1)
To make this valid Groovy code, fix the constructor invocations, i.e. replace this:
SVALUE(prop:"1", num: 1),
PVALUE(prop:"5", num: 3);
with
SVALUE("1", 1)
PVALUE("5", 3)
Upvotes: 1