@@ -29,23 +29,10 @@ final class AdapterHelper {
29
29
}
30
30
31
31
void write () {
32
- final var annotations = elementAnnotations .annotations ();
33
32
final var typeUse1 = elementAnnotations .typeUse1 ();
34
33
final var typeUse2 = elementAnnotations .typeUse2 ();
35
34
final var hasValid = elementAnnotations .hasValid ();
36
- boolean first = true ;
37
- for (final var a : annotations .entrySet ()) {
38
- if (first ) {
39
- writer .append ("%sctx.<%s>adapter(%s.class, %s)" , indent , type , a .getKey ().shortName (), a .getValue ());
40
- first = false ;
41
- continue ;
42
- }
43
- writer .eol ().append ("%s .andThen(ctx.adapter(%s.class,%s))" , indent , a .getKey ().shortName (), a .getValue ());
44
- }
45
-
46
- if (annotations .isEmpty ()) {
47
- writer .append ("%sctx.<%s>noop()" , indent , type );
48
- }
35
+ writeFirst (elementAnnotations .annotations ());
49
36
50
37
if (!typeUse1 .isEmpty () && (isAssignable2Interface (genericType .topType (), "java.lang.Iterable" ))) {
51
38
writer .eol ().append ("%s .list()" , indent );
@@ -58,9 +45,7 @@ void write() {
58
45
writer .eol ().append ("%s .andThenMulti(ctx.adapter(%s.class))" , indent , Util .shortName (topType .firstParamType ()));
59
46
}
60
47
61
- } else if ((!typeUse1 .isEmpty () || !typeUse2 .isEmpty ())
62
- && "java.util.Map" .equals (genericType .topType ())) {
63
-
48
+ } else if (isMapType (typeUse1 , typeUse2 )) {
64
49
writer .eol ().append ("%s .mapKeys()" , indent );
65
50
writeTypeUse (genericType .firstParamType (), typeUse1 );
66
51
@@ -81,11 +66,28 @@ void write() {
81
66
}
82
67
}
83
68
84
- private boolean isTopTypeIterable () {
85
- if (topType != null && isAssignable2Interface (topType .topType (), "java.lang.Iterable" )) {
86
- return true ;
69
+ private void writeFirst (Map <GenericType , String > annotations ) {
70
+ boolean first = true ;
71
+ for (final var a : annotations .entrySet ()) {
72
+ if (first ) {
73
+ writer .append ("%sctx.<%s>adapter(%s.class, %s)" , indent , type , a .getKey ().shortName (), a .getValue ());
74
+ first = false ;
75
+ continue ;
76
+ }
77
+ writer .eol ().append ("%s .andThen(ctx.adapter(%s.class,%s))" , indent , a .getKey ().shortName (), a .getValue ());
87
78
}
88
- return false ;
79
+ if (annotations .isEmpty ()) {
80
+ writer .append ("%sctx.<%s>noop()" , indent , type );
81
+ }
82
+ }
83
+
84
+ private boolean isMapType (Map <GenericType , String > typeUse1 , Map <GenericType , String > typeUse2 ) {
85
+ return (!typeUse1 .isEmpty () || !typeUse2 .isEmpty ())
86
+ && "java.util.Map" .equals (genericType .topType ());
87
+ }
88
+
89
+ private boolean isTopTypeIterable () {
90
+ return topType != null && isAssignable2Interface (topType .topType (), "java.lang.Iterable" );
89
91
}
90
92
91
93
private void writeTypeUse (String firstParamType , Map <GenericType , String > typeUse12 ) {
0 commit comments