|
18 | 18 | * See the License for the specific language governing permissions and |
19 | 19 | * limitations under the License. |
20 | 20 | */ |
21 | | -package io.github.nename0.moshi.java.codegen; |
| 21 | +package com.github.nename0.moshi.java.codegen; |
22 | 22 |
|
23 | 23 | import com.squareup.javapoet.ClassName; |
24 | 24 | import com.squareup.javapoet.TypeName; |
|
28 | 28 |
|
29 | 29 | import javax.annotation.processing.ProcessingEnvironment; |
30 | 30 | import javax.annotation.processing.RoundEnvironment; |
31 | | -import javax.lang.model.element.*; |
32 | | -import javax.lang.model.type.DeclaredType; |
| 31 | +import javax.lang.model.element.Element; |
| 32 | +import javax.lang.model.element.ElementKind; |
| 33 | +import javax.lang.model.element.ExecutableElement; |
| 34 | +import javax.lang.model.element.TypeElement; |
33 | 35 | import javax.lang.model.type.TypeKind; |
34 | | -import javax.lang.model.type.TypeMirror; |
35 | 36 | import javax.lang.model.util.ElementFilter; |
36 | 37 | import javax.lang.model.util.Elements; |
37 | 38 | import java.io.PrintWriter; |
38 | 39 | import java.io.StringWriter; |
39 | 40 | import java.lang.annotation.Annotation; |
40 | 41 | import java.util.List; |
41 | 42 | import java.util.Map; |
42 | | -import java.util.Set; |
43 | 43 | import java.util.stream.Collectors; |
44 | 44 |
|
45 | 45 | import static javax.lang.model.element.Modifier.*; |
@@ -72,12 +72,12 @@ public void findAndParseObjects(RoundEnvironment env, Map<String, JsonClassHolde |
72 | 72 | if (!annotation.generateAdapter() || !JsonClassCodegenProcessor.GENERATOR_NAME.equals(annotation.generator())) { |
73 | 73 | continue; |
74 | 74 | } |
75 | | - if (elem.getKind() != ElementKind.CLASS || !(elem instanceof TypeElement)) { |
| 75 | + if (elem.getKind() != ElementKind.CLASS || !(elem instanceof TypeElement typeElement)) { |
76 | 76 | error(elem, "@JsonClass can't be applied to %s - %s: must be a Class type.", elem.getEnclosingElement().toString(), elem.toString()); |
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | try { |
80 | | - processJsonClassAnnotation((TypeElement) elem, jsonClassMap); |
| 80 | + processJsonClassAnnotation(typeElement, jsonClassMap); |
81 | 81 | } catch (Exception e) { |
82 | 82 | StringWriter stackTrace = new StringWriter(); |
83 | 83 | e.printStackTrace(new PrintWriter(stackTrace)); |
@@ -135,11 +135,11 @@ private boolean checkClassAccessibleFromPackage(TypeElement element) { |
135 | 135 | return false; |
136 | 136 | } |
137 | 137 | Element parent = current.getEnclosingElement(); |
138 | | - if (parent.asType().getKind() != TypeKind.DECLARED || !(parent instanceof TypeElement)) { |
| 138 | + if (parent.asType().getKind() != TypeKind.DECLARED || !(parent instanceof TypeElement child)) { |
139 | 139 | error(parent, "Expected %s(%s) nesting %s to be a class/interface", parent.getSimpleName(), parent.getKind().toString(), current.getQualifiedName()); |
140 | 140 | return false; |
141 | 141 | } |
142 | | - current = (TypeElement) parent; |
| 142 | + current = child; |
143 | 143 | } |
144 | 144 | return true; |
145 | 145 | } |
|
0 commit comments