Skip to content

Commit 38eb844

Browse files
simopeteWonderCsabo
authored andcommitted
Fix @ebean validation on interface
1 parent 966520b commit 38eb844

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

  • AndroidAnnotations/androidannotations-core

‎AndroidAnnotations/androidannotations-core/androidannotations-api/src/main/java/org/androidannotations/annotations/EBean.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
* create Abstract classes that handle common code.
3939
* </p>
4040
* <p>
41+
* {@link EBean} can only be used on classes and NOT on interfaces.
42+
* If you want to use an {@link EBean} with interface you must annotate
43+
* the implementation class and not the interface.
44+
* </p>
45+
* <p>
4146
* Most annotations are supported in {@link EBean} classes, except the ones
4247
* related to extras. Views related annotations will only work if the bean was
4348
* injected in an activity with a layout containing the views you're dealing

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ public void isInterface(TypeElement element, ElementValidation valid) {
106106
}
107107
}
108108

109+
public void isNotInterface(TypeElement element, ElementValidation valid) {
110+
if (annotationHelper.isInterface(element)) {
111+
valid.addError("%s cannot be used on an interface");
112+
}
113+
}
114+
109115
public void isTopLevel(TypeElement element, ElementValidation valid) {
110116
if (!annotationHelper.isTopLevel(element)) {
111117
valid.addError("%s can only be used on a top level type");

‎AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/internal/core/handler/EBeanHandler.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public EBeanHolder createGeneratedClassHolder(AndroidAnnotationsEnvironment envi
3939
public void validate(Element element, ElementValidation valid) {
4040
super.validate(element, valid);
4141

42+
validatorHelper.isNotInterface((TypeElement) element, valid);
43+
4244
validatorHelper.isNotPrivate(element, valid);
4345

4446
validatorHelper.isAbstractOrHasEmptyOrContextConstructor(element, valid);

0 commit comments

Comments
 (0)