(file_name, out, preamble, js_map)
| 148 | |
| 149 | |
| 150 | def generate_java_source(file_name, out, preamble, js_map): |
| 151 | if not file_name.endswith(".java"): |
| 152 | raise RuntimeError("File name must end in .java") |
| 153 | class_name = os.path.basename(file_name[:-5]) |
| 154 | |
| 155 | out.write(_copyright) |
| 156 | out.write("\n") |
| 157 | out.write(preamble) |
| 158 | out.write("") |
| 159 | out.write( |
| 160 | f""" |
| 161 | public enum {class_name} {{ |
| 162 | |
| 163 | // AUTO GENERATED - DO NOT EDIT BY HAND |
| 164 | """ |
| 165 | ) |
| 166 | |
| 167 | for name, file in js_map.items(): |
| 168 | contents = open(file).read() |
| 169 | write_atom_literal(out, name, contents, "java", True) |
| 170 | |
| 171 | out.write( |
| 172 | f""" |
| 173 | ; |
| 174 | private final String value; |
| 175 | |
| 176 | public String getValue() {{ |
| 177 | return value; |
| 178 | }} |
| 179 | |
| 180 | public String toString() {{ |
| 181 | return getValue(); |
| 182 | }} |
| 183 | |
| 184 | {class_name}(String value) {{ |
| 185 | this.value = value; |
| 186 | }} |
| 187 | }} |
| 188 | """ |
| 189 | ) |
| 190 | |
| 191 | |
| 192 | def main(argv=[]): |
no test coverage detected