-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle short/long integer enums (#770)
This fixes #771
- Loading branch information
1 parent
b611629
commit 3ac61fd
Showing
9 changed files
with
384 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...enerator/src/test/java/mada/tests/e2e/dto/enums/integers/api/Customer_InformationApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* openapi API Title | ||
* openapi API description | ||
* | ||
* The version of the OpenAPI document: openapi API Version | ||
*/ | ||
|
||
package mada.tests.e2e.dto.enums.integers.api; | ||
|
||
import javax.ws.rs.*; | ||
import org.eclipse.microprofile.openapi.annotations.Operation; | ||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; | ||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponses; | ||
|
||
@javax.annotation.processing.Generated(value = "dk.mada.jaxrs.Generator") | ||
@Path("/v1/customers/engagements") | ||
public interface Customer_InformationApi { | ||
|
||
/** | ||
* Get engagements (refNo) for a specific customer. | ||
*/ | ||
@GET | ||
@APIResponses({ | ||
@APIResponse(responseCode = "200", description = "") | ||
}) | ||
@Operation(summary = "Get engagements (refNo) for a specific customer.") | ||
void getCustomerEngagement(); | ||
} |
121 changes: 121 additions & 0 deletions
121
...les/generator/src/test/java/mada/tests/e2e/dto/enums/integers/dto/CustomerEngagement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* openapi API Title | ||
* openapi API description | ||
* | ||
* The version of the OpenAPI document: openapi API Version | ||
*/ | ||
|
||
package mada.tests.e2e.dto.enums.integers.dto; | ||
|
||
import java.util.Objects; | ||
import javax.json.bind.annotation.JsonbProperty; | ||
import javax.validation.Valid; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
/** | ||
* Customer Engagement information. | ||
* | ||
*/ | ||
@Schema(description = "Customer Engagement information.\n") | ||
@javax.annotation.processing.Generated(value = "dk.mada.jaxrs.Generator") | ||
public class CustomerEngagement { | ||
public static final String JSON_PROPERTY_ROLE_CODE_INT = "roleCodeInt"; | ||
@JsonbProperty(JSON_PROPERTY_ROLE_CODE_INT) | ||
private RoleCodeInt roleCodeInt; | ||
|
||
public static final String JSON_PROPERTY_ROLE_CODE_LONG = "roleCodeLong"; | ||
@JsonbProperty(JSON_PROPERTY_ROLE_CODE_LONG) | ||
private RoleCodeLong roleCodeLong; | ||
|
||
public static final String JSON_PROPERTY_ROLE_CODE_SHORT = "roleCodeShort"; | ||
@JsonbProperty(JSON_PROPERTY_ROLE_CODE_SHORT) | ||
private RoleCodeShort roleCodeShort; | ||
|
||
public CustomerEngagement roleCodeInt(RoleCodeInt roleCodeInt) { | ||
this.roleCodeInt = roleCodeInt; | ||
return this; | ||
} | ||
|
||
/** | ||
* Get roleCodeInt | ||
* @return roleCodeInt | ||
**/ | ||
@Valid | ||
public RoleCodeInt getRoleCodeInt() { | ||
return roleCodeInt; | ||
} | ||
|
||
public void setRoleCodeInt(RoleCodeInt roleCodeInt) { | ||
this.roleCodeInt = roleCodeInt; | ||
} | ||
|
||
public CustomerEngagement roleCodeLong(RoleCodeLong roleCodeLong) { | ||
this.roleCodeLong = roleCodeLong; | ||
return this; | ||
} | ||
|
||
/** | ||
* Get roleCodeLong | ||
* @return roleCodeLong | ||
**/ | ||
@Valid | ||
public RoleCodeLong getRoleCodeLong() { | ||
return roleCodeLong; | ||
} | ||
|
||
public void setRoleCodeLong(RoleCodeLong roleCodeLong) { | ||
this.roleCodeLong = roleCodeLong; | ||
} | ||
|
||
public CustomerEngagement roleCodeShort(RoleCodeShort roleCodeShort) { | ||
this.roleCodeShort = roleCodeShort; | ||
return this; | ||
} | ||
|
||
/** | ||
* Get roleCodeShort | ||
* @return roleCodeShort | ||
**/ | ||
@Valid | ||
public RoleCodeShort getRoleCodeShort() { | ||
return roleCodeShort; | ||
} | ||
|
||
public void setRoleCodeShort(RoleCodeShort roleCodeShort) { | ||
this.roleCodeShort = roleCodeShort; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof CustomerEngagement)) { | ||
return false; | ||
} | ||
CustomerEngagement other = (CustomerEngagement) o; | ||
return Objects.equals(this.roleCodeInt, other.roleCodeInt) && | ||
Objects.equals(this.roleCodeLong, other.roleCodeLong) && | ||
Objects.equals(this.roleCodeShort, other.roleCodeShort); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(roleCodeInt, roleCodeLong, roleCodeShort); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("class CustomerEngagement {"); | ||
sb.append("\n roleCodeInt: ").append(toIndentedString(roleCodeInt)); | ||
sb.append("\n roleCodeLong: ").append(toIndentedString(roleCodeLong)); | ||
sb.append("\n roleCodeShort: ").append(toIndentedString(roleCodeShort)); | ||
sb.append("\n}"); | ||
return sb.toString(); | ||
} | ||
|
||
private String toIndentedString(Object o) { | ||
return Objects.toString(o).replace("\n", "\n "); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
modules/generator/src/test/java/mada/tests/e2e/dto/enums/integers/dto/RoleCodeInt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* openapi API Title | ||
* openapi API description | ||
* | ||
* The version of the OpenAPI document: openapi API Version | ||
*/ | ||
|
||
package mada.tests.e2e.dto.enums.integers.dto; | ||
|
||
import javax.json.Json; | ||
import javax.json.JsonString; | ||
import javax.json.bind.adapter.JsonbAdapter; | ||
import javax.json.bind.annotation.JsonbTypeAdapter; | ||
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
/** | ||
* Role for the customer refnr relation. 1=Owner, 0=Related, Unknown role. | ||
*/ | ||
@JsonbTypeAdapter(mada.tests.e2e.dto.enums.integers.dto.RoleCodeInt.RoleCodeIntAdapter.class) | ||
@Schema(enumeration = {"0", "1"}, type = SchemaType.INTEGER, format = "int32", description = "Role for the customer refnr relation. 1=Owner, 0=Related, Unknown role.") | ||
@javax.annotation.processing.Generated(value = "dk.mada.jaxrs.Generator") | ||
public enum RoleCodeInt { | ||
NUMBER_0(0), | ||
NUMBER_1(1); | ||
|
||
private final int value; | ||
|
||
RoleCodeInt(int value) { | ||
this.value = value; | ||
} | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.valueOf(value); | ||
} | ||
|
||
public static class RoleCodeIntAdapter implements JsonbAdapter<RoleCodeInt, JsonString> { | ||
@Override | ||
public JsonString adaptToJson(RoleCodeInt e) throws Exception { | ||
return Json.createValue(String.valueOf(e.value)); | ||
} | ||
|
||
@Override | ||
public RoleCodeInt adaptFromJson(JsonString value) throws Exception { | ||
for (RoleCodeInt b : RoleCodeInt.values()) { | ||
if (String.valueOf(b.value).equalsIgnoreCase(value.getString())) { | ||
return b; | ||
} | ||
} | ||
throw new IllegalStateException("Unable to deserialize '" + value.getString() + "' to type RoleCodeInt"); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
modules/generator/src/test/java/mada/tests/e2e/dto/enums/integers/dto/RoleCodeLong.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* openapi API Title | ||
* openapi API description | ||
* | ||
* The version of the OpenAPI document: openapi API Version | ||
*/ | ||
|
||
package mada.tests.e2e.dto.enums.integers.dto; | ||
|
||
import javax.json.Json; | ||
import javax.json.JsonString; | ||
import javax.json.bind.adapter.JsonbAdapter; | ||
import javax.json.bind.annotation.JsonbTypeAdapter; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
/** | ||
* Role for the customer refnr relation. 1=Owner, 0=Related, Unknown role. | ||
*/ | ||
@JsonbTypeAdapter(mada.tests.e2e.dto.enums.integers.dto.RoleCodeLong.RoleCodeLongAdapter.class) | ||
@Schema(enumeration = {"0", "1"}, description = "Role for the customer refnr relation. 1=Owner, 0=Related, Unknown role.") | ||
@javax.annotation.processing.Generated(value = "dk.mada.jaxrs.Generator") | ||
public enum RoleCodeLong { | ||
NUMBER_0(0L), | ||
NUMBER_1(1L); | ||
|
||
private final long value; | ||
|
||
RoleCodeLong(long value) { | ||
this.value = value; | ||
} | ||
|
||
public long getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.valueOf(value); | ||
} | ||
|
||
public static class RoleCodeLongAdapter implements JsonbAdapter<RoleCodeLong, JsonString> { | ||
@Override | ||
public JsonString adaptToJson(RoleCodeLong e) throws Exception { | ||
return Json.createValue(String.valueOf(e.value)); | ||
} | ||
|
||
@Override | ||
public RoleCodeLong adaptFromJson(JsonString value) throws Exception { | ||
for (RoleCodeLong b : RoleCodeLong.values()) { | ||
if (String.valueOf(b.value).equalsIgnoreCase(value.getString())) { | ||
return b; | ||
} | ||
} | ||
throw new IllegalStateException("Unable to deserialize '" + value.getString() + "' to type RoleCodeLong"); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
modules/generator/src/test/java/mada/tests/e2e/dto/enums/integers/dto/RoleCodeShort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* openapi API Title | ||
* openapi API description | ||
* | ||
* The version of the OpenAPI document: openapi API Version | ||
*/ | ||
|
||
package mada.tests.e2e.dto.enums.integers.dto; | ||
|
||
import javax.json.Json; | ||
import javax.json.JsonString; | ||
import javax.json.bind.adapter.JsonbAdapter; | ||
import javax.json.bind.annotation.JsonbTypeAdapter; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
/** | ||
* Role for the customer refnr relation. 1=Owner, 0=Related, Unknown role. | ||
*/ | ||
@JsonbTypeAdapter(mada.tests.e2e.dto.enums.integers.dto.RoleCodeShort.RoleCodeShortAdapter.class) | ||
@Schema(enumeration = {"0", "1"}, description = "Role for the customer refnr relation. 1=Owner, 0=Related, Unknown role.") | ||
@javax.annotation.processing.Generated(value = "dk.mada.jaxrs.Generator") | ||
public enum RoleCodeShort { | ||
NUMBER_0((short)0), | ||
NUMBER_1((short)1); | ||
|
||
private final short value; | ||
|
||
RoleCodeShort(short value) { | ||
this.value = value; | ||
} | ||
|
||
public short getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.valueOf(value); | ||
} | ||
|
||
public static class RoleCodeShortAdapter implements JsonbAdapter<RoleCodeShort, JsonString> { | ||
@Override | ||
public JsonString adaptToJson(RoleCodeShort e) throws Exception { | ||
return Json.createValue(String.valueOf(e.value)); | ||
} | ||
|
||
@Override | ||
public RoleCodeShort adaptFromJson(JsonString value) throws Exception { | ||
for (RoleCodeShort b : RoleCodeShort.values()) { | ||
if (String.valueOf(b.value).equalsIgnoreCase(value.getString())) { | ||
return b; | ||
} | ||
} | ||
throw new IllegalStateException("Unable to deserialize '" + value.getString() + "' to type RoleCodeShort"); | ||
} | ||
} | ||
} |
Oops, something went wrong.