Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Commit 1561b48

Browse files
committed
Merge pull request #1093 from dodgex/AllowConstructorsForAbstact
Implement #1081 (allow any constructors for EFragment)
2 parents ec77c66 + 65e64af commit 1561b48

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/handler/EFragmentHandler.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void validate(Element element, AnnotationElements validatedElements, IsVa
5454

5555
validatorHelper.isNotPrivate(element, valid);
5656

57-
validatorHelper.hasEmptyConstructor(element, valid);
57+
validatorHelper.isAbstractOrHasEmptyConstructor(element, valid);
5858

5959
validatorHelper.extendsFragment(element, valid);
6060
}

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/ValidatorHelper.java‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -894,26 +894,26 @@ public void isAbstractOrHasEmptyOrContextConstructor(Element element, IsValid va
894894
}
895895
}
896896

897-
public void hasEmptyConstructor(Element element, IsValid valid) {
898-
897+
public void isAbstractOrHasEmptyConstructor(Element element, IsValid valid) {
899898
List<ExecutableElement> constructors = ElementFilter.constructorsIn(element.getEnclosedElements());
900899

901-
if (constructors.size() == 1) {
902-
903-
ExecutableElement constructor = constructors.get(0);
900+
if (!annotationHelper.isAbstract(element)) {
901+
if (constructors.size() == 1) {
902+
ExecutableElement constructor = constructors.get(0);
904903

905-
if (!annotationHelper.isPrivate(constructor)) {
906-
if (constructor.getParameters().size() != 0) {
907-
annotationHelper.printAnnotationError(element, "%s annotated element should have an empty constructor");
904+
if (!annotationHelper.isPrivate(constructor)) {
905+
if (constructor.getParameters().size() != 0) {
906+
annotationHelper.printAnnotationError(element, "%s annotated element should have an empty constructor");
907+
valid.invalidate();
908+
}
909+
} else {
910+
annotationHelper.printAnnotationError(element, "%s annotated element should not have a private constructor");
908911
valid.invalidate();
909912
}
910913
} else {
911-
annotationHelper.printAnnotationError(element, "%s annotated element should not have a private constructor");
914+
annotationHelper.printAnnotationError(element, "%s annotated element should have only one constructor");
912915
valid.invalidate();
913916
}
914-
} else {
915-
annotationHelper.printAnnotationError(element, "%s annotated element should have only one constructor");
916-
valid.invalidate();
917917
}
918918
}
919919

0 commit comments

Comments
 (0)