|
7 | 7 | import java.io.IOException; |
8 | 8 | import java.io.OutputStreamWriter; |
9 | 9 | import java.io.Writer; |
| 10 | +import java.nio.charset.StandardCharsets; |
10 | 11 | import java.util.Arrays; |
11 | 12 | import java.util.EnumSet; |
12 | 13 | import java.util.HashMap; |
|
21 | 22 | public class ClassWriter extends JavaWriter { |
22 | 23 |
|
23 | 24 | public static final String SLDN_URL_BASE_PATH = "http://sldn.softlayer.com/reference/"; |
24 | | - |
| 25 | + |
25 | 26 | public static final String TYPE_API_CLIENT = "com.softlayer.api.ApiClient"; |
26 | 27 | public static final String TYPE_API_METHOD = "com.softlayer.api.annotation.ApiMethod"; |
27 | 28 | public static final String TYPE_API_PROPERTY = "com.softlayer.api.annotation.ApiProperty"; |
@@ -63,7 +64,7 @@ public static void emitType(File baseDir, TypeClass type, Meta meta) throws IOEx |
63 | 64 | File fileDir = new File(baseDir, type.packageName.replace('.', '/')); |
64 | 65 | fileDir.mkdirs(); |
65 | 66 | Writer writer = new BufferedWriter(new OutputStreamWriter( |
66 | | - new FileOutputStream(new File(fileDir, type.className + ".java")), "UTF-8")); |
| 67 | + new FileOutputStream(new File(fileDir, type.className + ".java")), StandardCharsets.UTF_8)); |
67 | 68 | try { |
68 | 69 | new ClassWriter(writer, type, meta).emitType(); |
69 | 70 | } finally { |
@@ -97,7 +98,7 @@ public ClassWriter(Writer out, TypeClass type, Meta meta) { |
97 | 98 |
|
98 | 99 | public ClassWriter emitAnnotationWithAttrs(String annotationType, Object... attributes) throws IOException { |
99 | 100 | int i = 0; |
100 | | - Map<String, Object> attrMap = new HashMap<String, Object>(attributes.length / 2 + 1); |
| 101 | + Map<String, Object> attrMap = new HashMap<>(attributes.length / 2 + 1); |
101 | 102 | while (i < attributes.length) { |
102 | 103 | String key = attributes[i++].toString(); |
103 | 104 | attrMap.put(key, attributes[i++]); |
@@ -134,7 +135,7 @@ public ClassWriter emitProperty(TypeClass.Property property) throws IOException |
134 | 135 | emitJavadoc(property.meta.doc.replace("\n", "<br />\n")); |
135 | 136 | } |
136 | 137 |
|
137 | | - Map<String, Object> params = new HashMap<String, Object>(2); |
| 138 | + Map<String, Object> params = new HashMap<>(2); |
138 | 139 | if (!property.name.equals(property.meta.name)) { |
139 | 140 | params.put("value", stringLiteral(property.meta.name)); |
140 | 141 | } |
@@ -267,7 +268,7 @@ public ClassWriter emitServiceMethod(TypeClass.Method method, boolean async) thr |
267 | 268 | "/" + method.meta.name + "\">" + type.meta.name + "::" + method.meta.name + "</a>"; |
268 | 269 | emitJavadoc(javadoc); |
269 | 270 |
|
270 | | - Map<String, Object> params = new HashMap<String, Object>(2); |
| 271 | + Map<String, Object> params = new HashMap<>(2); |
271 | 272 | if (!method.name.equals(method.meta.name)) { |
272 | 273 | params.put("value", stringLiteral(method.meta.name)); |
273 | 274 | } |
@@ -433,8 +434,8 @@ public ClassWriter emitType() throws IOException { |
433 | 434 | } |
434 | 435 |
|
435 | 436 | public ClassWriter emitTypeImports() throws IOException { |
436 | | - Map<String, String> imports = new HashMap<String, String>(type.imports); |
437 | | - |
| 437 | + Map<String, String> imports = new HashMap<>(type.imports); |
| 438 | + |
438 | 439 | imports.remove("Mask"); |
439 | 440 | imports.remove(type.className); |
440 | 441 | imports.put("ApiType", TYPE_API_TYPE); |
|
0 commit comments