Skip to content

Commit 465208f

Browse files
authored
chore: register enum traits for marshalling round-trip (#37)
1 parent e7641cc commit 465208f

14 files changed

Lines changed: 125 additions & 16 deletions

File tree

codemodel-foundation/src/test/java/build/codemodel/foundation/CodeModelCompatibilityTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package build.codemodel.foundation;
22

33
import build.base.foundation.stream.Streamable;
4+
import build.base.marshalling.Marshalling;
45
import build.base.query.Indexable;
56
import build.base.telemetry.Location;
67
import build.codemodel.foundation.descriptor.AbstractTypeDescriptor;
@@ -622,6 +623,10 @@ enum Color
622623
*/
623624
@Indexable
624625
public static final Function<Color, String> NAME = Color::name;
626+
627+
static {
628+
Marshalling.registerEnum(CodeModelCompatibilityTests.Color.class);
629+
}
625630
}
626631

627632
/**

codemodel-foundation/src/test/java/build/codemodel/foundation/ConceptualCodeModelTests.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package build.codemodel.foundation;
22

33
import build.base.foundation.stream.Streamable;
4+
import build.base.marshalling.Marshalling;
45
import build.base.mereology.Strategy;
56
import build.base.query.Indexable;
67
import build.codemodel.foundation.descriptor.AbstractTraitable;
@@ -283,7 +284,11 @@ public enum Color
283284
implements Trait {
284285
RED,
285286
GREEN,
286-
BLUE
287+
BLUE;
288+
289+
static {
290+
Marshalling.registerEnum(ConceptualCodeModelTests.Color.class);
291+
}
287292
}
288293

289294
@Singular
@@ -292,7 +297,11 @@ public enum Speed
292297

293298
FAST,
294299
SLOW,
295-
MEDIUM
300+
MEDIUM;
301+
302+
static {
303+
Marshalling.registerEnum(ConceptualCodeModelTests.Speed.class);
304+
}
296305
}
297306

298307
public static class Wheel

codemodel-foundation/src/test/java/build/codemodel/foundation/TraitableCompatibilityTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package build.codemodel.foundation;
22

3+
import build.base.marshalling.Marshalling;
34
import build.base.mereology.Strategy;
45
import build.codemodel.foundation.descriptor.NonSingular;
56
import build.codemodel.foundation.descriptor.Singular;
@@ -296,6 +297,10 @@ enum Color
296297
BLUE,
297298
YELLOW,
298299
PURPLE;
300+
301+
static {
302+
Marshalling.registerEnum(TraitableCompatibilityTests.Color.class);
303+
}
299304
}
300305

301306
@Singular

jdk-codemodel/src/main/java/build/codemodel/jdk/descriptor/AnnotationType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* #L%
2121
*/
2222

23+
import build.base.marshalling.Marshalling;
2324
import build.codemodel.foundation.descriptor.Trait;
2425

2526
/**
@@ -34,4 +35,8 @@ public enum AnnotationType implements Trait {
3435
* Indicates that a type is an annotation type.
3536
*/
3637
ANNOTATION_TYPE;
38+
39+
static {
40+
Marshalling.registerEnum(AnnotationType.class);
41+
}
3742
}

jdk-codemodel/src/main/java/build/codemodel/jdk/descriptor/EnumType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* #L%
2121
*/
2222

23+
import build.base.marshalling.Marshalling;
2324
import build.codemodel.foundation.descriptor.Trait;
2425

2526
/**
@@ -34,4 +35,8 @@ public enum EnumType implements Trait {
3435
* Indicates that a type is an enum.
3536
*/
3637
ENUM;
38+
39+
static {
40+
Marshalling.registerEnum(EnumType.class);
41+
}
3742
}

jdk-codemodel/src/main/java/build/codemodel/jdk/descriptor/Final.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* #L%
2121
*/
2222

23+
import build.base.marshalling.Marshalling;
2324
import build.codemodel.foundation.descriptor.Trait;
2425

2526
/**
@@ -35,4 +36,8 @@ public enum Final
3536
* Indicates that a parameter is {@code final}.
3637
*/
3738
FINAL;
39+
40+
static {
41+
Marshalling.registerEnum(Final.class);
42+
}
3843
}

jdk-codemodel/src/main/java/build/codemodel/jdk/descriptor/OpenModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* #L%
2121
*/
2222

23+
import build.base.marshalling.Marshalling;
2324
import build.codemodel.foundation.descriptor.Singular;
2425
import build.codemodel.foundation.descriptor.Trait;
2526

@@ -36,4 +37,8 @@ public enum OpenModule implements Trait {
3637
* Indicates the module is an open module.
3738
*/
3839
OPEN;
40+
41+
static {
42+
Marshalling.registerEnum(OpenModule.class);
43+
}
3944
}

jdk-codemodel/src/main/java/build/codemodel/jdk/descriptor/RecordType.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
1111
* You may obtain a copy of the License at
12-
*
12+
*
1313
* http://www.apache.org/licenses/LICENSE-2.0
14-
*
14+
*
1515
* Unless required by applicable law or agreed to in writing, software
1616
* distributed under the License is distributed on an "AS IS" BASIS,
1717
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,7 @@
2020
* #L%
2121
*/
2222

23+
import build.base.marshalling.Marshalling;
2324
import build.codemodel.foundation.descriptor.Trait;
2425

2526
/**
@@ -34,4 +35,8 @@ public enum RecordType implements Trait {
3435
* Indicates that a type is a record.
3536
*/
3637
RECORD;
38+
39+
static {
40+
Marshalling.registerEnum(RecordType.class);
41+
}
3742
}

jdk-codemodel/src/main/java/build/codemodel/jdk/descriptor/RequiresModifier.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* #L%
2121
*/
2222

23+
import build.base.marshalling.Marshalling;
2324
import build.codemodel.foundation.descriptor.NonSingular;
2425
import build.codemodel.foundation.descriptor.Trait;
2526

@@ -42,4 +43,8 @@ public enum RequiresModifier implements Trait {
4243
* {@code requires static} — the dependency is required at compile time only.
4344
*/
4445
STATIC;
46+
47+
static {
48+
Marshalling.registerEnum(RequiresModifier.class);
49+
}
4550
}

jdk-codemodel/src/main/java/build/codemodel/jdk/descriptor/Static.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* #L%
2121
*/
2222

23+
import build.base.marshalling.Marshalling;
2324
import build.codemodel.foundation.descriptor.Trait;
2425

2526
/**
@@ -35,4 +36,8 @@ public enum Static
3536
* Indicates that a definition is {@code static}.
3637
*/
3738
STATIC;
39+
40+
static {
41+
Marshalling.registerEnum(Static.class);
42+
}
3843
}

0 commit comments

Comments
 (0)