Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/quicktype-core/src/language/Java/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ export function javaNameStyle(
upperUnderscore
? allUpperWordStyle
: startWithUpper
? firstUpperWordStyle
: allLowerWordStyle,
? firstUpperWordStyle
: allLowerWordStyle,
upperUnderscore ? allUpperWordStyle : firstUpperWordStyle,
upperUnderscore || startWithUpper
? allUpperWordStyle
: allLowerWordStyle,
acronymsStyle,
// For UPPER_UNDERSCORE style (Java enum constants), always use allUpperWordStyle for acronyms
// to maintain consistency with the naming convention (e.g., XXX_SPA_XXX)
upperUnderscore ? allUpperWordStyle : acronymsStyle,
upperUnderscore ? "_" : "",
isStartCharacter,
);
Expand Down
42 changes: 42 additions & 0 deletions test/fixtures/java/src/main/java/io/quicktype/MessageCode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.quicktype;

import java.io.IOException;
import com.fasterxml.jackson.annotation.*;

public class MessageCode {
private Code code;

@JsonProperty("code")
public Code getCode() {
return code;
}

@JsonProperty("code")
public void setCode(Code value) {
this.code = value;
}

public enum Code {
MULTI_SPA_IN_GROUP_REJECTED, SOME_OTHER_VALUE;

@JsonValue
public String toValue() {
switch (this) {
case MULTI_SPA_IN_GROUP_REJECTED:
return "MULTI_SPA_IN_GROUP_REJECTED";
case SOME_OTHER_VALUE:
return "SOME_OTHER_VALUE";
}
return null;
}

@JsonCreator
public static Code forValue(String value) throws IOException {
if (value.equals("MULTI_SPA_IN_GROUP_REJECTED"))
return MULTI_SPA_IN_GROUP_REJECTED;
if (value.equals("SOME_OTHER_VALUE"))
return SOME_OTHER_VALUE;
throw new IOException("Cannot deserialize Code");
}
}
}
10 changes: 10 additions & 0 deletions test/inputs/json/priority/enum-spa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"code": {
"type": "string",
"enum": ["SOME_OTHER_VALUE", "MULTI_SPA_IN_GROUP_REJECTED"]
}
}
}
Loading