@@ -51,28 +51,36 @@ public SourceVersion getSupportedSourceVersion() {
5151 public boolean process (
5252 final Set <? extends TypeElement > annotations , final RoundEnvironment roundEnv ) {
5353 final ConversionServiceBridgeDescriptor descriptor = new ConversionServiceBridgeDescriptor ();
54- final MutablePair <String , String > bridgePackageAndClass =
54+ final Pair <String , String > bridgePackageAndClass =
5555 getBridgePackageAndClassName (annotations , roundEnv );
5656 descriptor .setBridgeClassName (
5757 ClassName .get (bridgePackageAndClass .getLeft (), bridgePackageAndClass .getRight ()));
58- for (final TypeElement annotation : annotations ) {
59- if (MAPPER .contentEquals (annotation .getQualifiedName ())) {
60- final List <Pair <ClassName , ClassName >> fromToMappings =
61- roundEnv .getElementsAnnotatedWith (annotation ).stream ()
62- .filter (mapper -> mapper .asType ().getKind () == DECLARED )
63- .filter (mapper -> getConverterSupertype (mapper ).isPresent ())
64- .map (this ::toConvertMethod )
65- .filter (Objects ::nonNull )
66- .map (ExecutableElement .class ::cast )
67- .map (this ::toFromToMapping )
68- .collect (toList ());
69- descriptor .setFromToMappings (fromToMappings );
70- writeBridgeClassFile (descriptor , bridgePackageAndClass );
71- }
72- }
58+ annotations .stream ()
59+ .filter (annotation -> MAPPER .contentEquals (annotation .getQualifiedName ()))
60+ .forEach (
61+ annotation ->
62+ processMapperAnnotation (roundEnv , descriptor , bridgePackageAndClass , annotation ));
7363 return false ;
7464 }
7565
66+ private void processMapperAnnotation (
67+ final RoundEnvironment roundEnv ,
68+ final ConversionServiceBridgeDescriptor descriptor ,
69+ final Pair <String , String > bridgePackageAndClass ,
70+ final TypeElement annotation ) {
71+ final List <Pair <ClassName , ClassName >> fromToMappings =
72+ roundEnv .getElementsAnnotatedWith (annotation ).stream ()
73+ .filter (mapper -> mapper .asType ().getKind () == DECLARED )
74+ .filter (mapper -> getConverterSupertype (mapper ).isPresent ())
75+ .map (this ::toConvertMethod )
76+ .filter (Objects ::nonNull )
77+ .map (ExecutableElement .class ::cast )
78+ .map (this ::toFromToMapping )
79+ .collect (toList ());
80+ descriptor .setFromToMappings (fromToMappings );
81+ writeBridgeClassFile (descriptor , bridgePackageAndClass );
82+ }
83+
7684 private Pair <ClassName , ClassName > toFromToMapping (final ExecutableElement convert ) {
7785 return Pair .of (
7886 (ClassName )
@@ -103,7 +111,7 @@ private Element toConvertMethod(final Element mapper) {
103111
104112 private void writeBridgeClassFile (
105113 final ConversionServiceBridgeDescriptor descriptor ,
106- final MutablePair <String , String > bridgePackageAndClass ) {
114+ final Pair <String , String > bridgePackageAndClass ) {
107115 try (final Writer outputWriter =
108116 processingEnv
109117 .getFiler ()
@@ -123,7 +131,7 @@ private void writeBridgeClassFile(
123131 }
124132 }
125133
126- private MutablePair <String , String > getBridgePackageAndClassName (
134+ private Pair <String , String > getBridgePackageAndClassName (
127135 final Set <? extends TypeElement > annotations , final RoundEnvironment roundEnv ) {
128136 final MutablePair <String , String > packageAndClass =
129137 MutablePair .of (
0 commit comments