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