Skip to content

Commit

Permalink
Add package-info.java and polish RemoveConstructorBindingAnnotation f…
Browse files Browse the repository at this point in the history
…qn check
  • Loading branch information
pway99 committed Jun 7, 2022
1 parent 5a37e8e commit 0b8a502
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.openrewrite.internal.ListUtils;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.TypeUtils;

/**
Expand All @@ -46,15 +45,8 @@ public JavaIsoVisitor<ExecutionContext> getVisitor() {
return new JavaIsoVisitor<ExecutionContext>() {
@Override
public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext context) {
boolean isConfigPropsAnnotationPresent = classDecl.getLeadingAnnotations().stream().filter(a -> {
JavaType.FullyQualified fqType = TypeUtils.asFullyQualified(a.getType());
if (fqType != null && ANNOTATION_CONFIG_PROPERTIES.equals(fqType.getFullyQualifiedName())) {
return true;
}
return false;
}).findFirst().isPresent();
J.ClassDeclaration c = super.visitClassDeclaration(classDecl, context);
if (isConfigPropsAnnotationPresent) {
if (classDecl.getLeadingAnnotations().stream().anyMatch(a -> TypeUtils.isOfClassType(a.getType(), ANNOTATION_CONFIG_PROPERTIES))) {
c = c.withLeadingAnnotations(ListUtils.map(c.getLeadingAnnotations(), anno -> {
if (TypeUtils.isOfClassType(anno.getType(), ANNOTATION_CONSTRUCTOR_BINDING)) {
maybeRemoveImport(ANNOTATION_CONSTRUCTOR_BINDING);
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/openrewrite/java/spring/boot3/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2021 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi @NonNullFields
package org.openrewrite.java.spring.boot3;

import org.openrewrite.internal.lang.NonNullApi;
import org.openrewrite.internal.lang.NonNullFields;

0 comments on commit 0b8a502

Please sign in to comment.