I am following a code from github . My problem now is that there is a line of code that tells me that it is private and that is why it gives me an error. I think I'm instantiating it right, but the error is still there.
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.api.CustomizationApi;
import org.openapitools.client.model.TaxCalculationSettingTypes;
import org.openapitools.client.model.TaxCalculationSettingsResponse;
class Example {...
TaxCalculationSettingTypes itemType = new TaxCalculationSettingTypes("Configuration");
try {
...
}
And in this line: TaxCalculationSettingTypes itemType = new TaxCalculationSettingTypes("Configuration");
it says error because TaxCalculationSettingTypes is private.
The TaxCalculationSettingTypes code is as follows:
@JsonAdapter(TaxCalculationSettingTypes.Adapter.class)
public enum TaxCalculationSettingTypes {
ALL("All"),
CONFIGURATION("Configuration"),
BUNDLE("Bundle"),
EXCLUSION("Exclusion"),
OVERRIDE("Override"),
NEXUS("Nexus"),
EXEMPTION("Exemption");
private String value;
private TaxCalculationSettingTypes(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
public String toString() {
return String.valueOf(this.value);
}
public static TaxCalculationSettingTypes fromValue(String value) {
TaxCalculationSettingTypes[] var1 = values();
int var2 = var1.length;
for(int var3 = 0; var3 < var2; ++var3) {
TaxCalculationSettingTypes b = var1[var3];
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter<TaxCalculationSettingTypes> {
public Adapter() {
}
public void write(JsonWriter jsonWriter, TaxCalculationSettingTypes enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
public TaxCalculationSettingTypes read(JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return TaxCalculationSettingTypes.fromValue(value);
}
}
}
If I leave it without parameters (like this one on github) it also throws an error, and if I put any of the enum options in String it also throws an error.
The error it returns is the following:
error: enum types may not be instantiated