• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

torand / jsonschema2java / 18399814123

10 Oct 2025 07:35AM UTC coverage: 78.214% (-0.9%) from 79.157%
18399814123

push

github

torand
fix: bean validation annotations on primitive subtypes of compound pojo property types now generated

287 of 413 branches covered (69.49%)

Branch coverage included in aggregate %.

440 of 533 new or added lines in 26 files covered. (82.55%)

1 existing line in 1 file now uncovered.

808 of 987 relevant lines covered (81.86%)

4.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/src/main/java/io/github/torand/jsonschema2java/writers/java/JavaEnumWriter.java
1
/*
2
 * Copyright (c) 2024-2025 Tore Eide Andersen
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package io.github.torand.jsonschema2java.writers.java;
17

18
import io.github.torand.jsonschema2java.generators.Options;
19
import io.github.torand.jsonschema2java.model.EnumInfo;
20
import io.github.torand.jsonschema2java.writers.BaseWriter;
21
import io.github.torand.jsonschema2java.writers.EnumWriter;
22

23
import java.io.Writer;
24

25
import static io.github.torand.javacommons.collection.CollectionHelper.nonEmpty;
26
import static io.github.torand.jsonschema2java.utils.StringUtils.joinCsv;
27

28
/**
29
 * Writes Java code for an enum.
30
 */
31
public class JavaEnumWriter extends BaseWriter implements EnumWriter {
32

33
    public JavaEnumWriter(Writer writer, Options opts) {
34
        super(writer, opts);
4✔
35
    }
1✔
36

37
    @Override
38
    public void write(EnumInfo enumInfo) {
39
        writeLine("package %s;", opts.getModelPackage(enumInfo.modelSubpackage()));
13✔
40
        writeNewLine();
2✔
41

42
        if (nonEmpty(enumInfo.aggregatedNormalImports())) {
4!
43
            enumInfo.aggregatedNormalImports().forEach(i -> writeLine("import %s;".formatted(i)));
18✔
44
            writeNewLine();
2✔
45
        }
46

47
        if (nonEmpty(enumInfo.aggregatedStaticImports())) {
4!
NEW
48
            enumInfo.aggregatedStaticImports().forEach(i -> writeLine("import static %s;".formatted(i)));
×
NEW
49
            writeNewLine();
×
50
        }
51

52
        enumInfo.annotationsAsStrings().forEach(this::writeLine);
11✔
53

54
        writeLine("public enum %s {".formatted(enumInfo.name()));
13✔
55
        writeIndent(1);
3✔
56
        writeLine(joinCsv(enumInfo.constants()));
7✔
57
        writeLine("}");
5✔
58
    }
1✔
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc