Skip to content

Commit 2447e63

Browse files
committed
restore original JEnum ctor and deprecate it (addressing review comments)
fix up CHANGELOG addition as the 7.2 ship has sailed. Signed-off-by: Keith Wall <[email protected]>
1 parent 0cad471 commit 2447e63

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
## CHANGELOG
22

3+
### 7.3-SNAPSHOT
4+
5+
#### Bugs
6+
7+
#### Improvements
8+
9+
#### Dependency Upgrade
10+
11+
#### New Features
12+
13+
* Fix #7045: (java-generator) Extend the existingJavaTypes to support use of existing enumerations
14+
315
### 7.2.0 (2025-04-30)
416

517
#### Bugs
@@ -28,7 +40,6 @@
2840

2941
#### New Features
3042
* Fix #6827: (crd-generator) Add CRDPostProcessor to process generated CRDs before they are written out
31-
* Fix #7045: (java-generator) Extend the existingJavaTypes to support use of existing enumerations
3243

3344
#### _**Note**_: Breaking changes
3445

java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JEnum.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ public JEnum(String pkg, String type, String underlyingType, List<JsonNode> valu
6161
this.pkgPrefixedType = createPackagePrefixedType(pkg, this.type);
6262
}
6363

64+
/**
65+
* @deprecated use {@link #JEnum(String, String, String, List, Config, String, boolean, JsonNode)}
66+
*/
67+
@Deprecated
68+
public JEnum(String type, String underlyingType, List<JsonNode> values, Config config, String description,
69+
final boolean isNullable, JsonNode defaultValue) {
70+
this(null, type, underlyingType, values, config, description, isNullable, defaultValue);
71+
}
72+
6473
private String createPackagePrefixedType(String pkg, String type) {
6574
String p = (pkg == null) ? "" : pkg.trim();
6675
String pkgPrefix = (p.isEmpty()) ? p : p + ".";

java-generator/core/src/test/java/io/fabric8/java/generator/GeneratorTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,32 @@ void testNotUppercaseEnum() {
629629
assertEquals("baz", en.get().getEntries().get(2).getName().asString());
630630
}
631631

632+
@Test
633+
void testEnumDeprecatedConstructor() {
634+
// Arrange
635+
JSONSchemaProps newEnum = new JSONSchemaProps();
636+
newEnum.setType("string");
637+
JEnum enu = new JEnum(
638+
"t",
639+
JAVA_LANG_STRING,
640+
List.of(),
641+
defaultConfig,
642+
null,
643+
Boolean.FALSE,
644+
null);
645+
646+
// Act
647+
GeneratorResult res = enu.generateJava();
648+
649+
// Assert
650+
assertEquals("T", enu.getType());
651+
assertEquals(1, res.getInnerClasses().size());
652+
assertEquals("T", res.getInnerClasses().get(0).getName());
653+
654+
Optional<EnumDeclaration> en = res.getInnerClasses().get(0).getEnumByName("T");
655+
assertTrue(en.isPresent());
656+
}
657+
632658
@Test
633659
void testArrayOfObjects() {
634660
// Arrange

0 commit comments

Comments
 (0)