Minor fixes for XML persistence generation.
The Android checkstyle configuration requires exactly the string "CHECKSTYLE: OFF Generated Code" in its SuppressionCommentFilter. JLS 4.12.4 says try-with-resources declaration is implicitly final, hence drop the redundant final modifier in generated code. Test: manual Change-Id: Idbb703d950601c32aececfc45e480698657ef764
This commit is contained in:
@@ -50,7 +50,7 @@ val FILE_HEADER = """
|
||||
*/
|
||||
|
||||
// Generated by xmlpersistence. DO NOT MODIFY!
|
||||
// CHECKSTYLE:OFF
|
||||
// CHECKSTYLE:OFF Generated code
|
||||
// @formatter:off
|
||||
""".trimIndent() + "\n\n"
|
||||
|
||||
@@ -128,9 +128,7 @@ private fun generateReadMethod(rootField: ClassFieldInfo): MethodSpec =
|
||||
.addAnnotation(nullableType)
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(rootField.type)
|
||||
.addControlFlow(
|
||||
"try (final \$1T inputStream = mFile.openRead())", FileInputStream::class.java
|
||||
) {
|
||||
.addControlFlow("try (\$1T inputStream = mFile.openRead())", FileInputStream::class.java) {
|
||||
addStatement("final \$1T parser = \$2T.newPullParser()", xmlPullParserType, xmlType)
|
||||
addStatement("parser.setInput(inputStream, null)")
|
||||
addStatement("return parse(parser)")
|
||||
|
||||
Reference in New Issue
Block a user