Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
* create Abstract classes that handle common code.
* </p>
* <p>
* {@link EBean} can only be used on classes and NOT on interfaces.
* If you want to use an {@link EBean} with interface you must annotate
* the implementation class and not the interface.
* </p>
* <p>
* Most annotations are supported in {@link EBean} classes, except the ones
* related to extras. Views related annotations will only work if the bean was
* injected in an activity with a layout containing the views you're dealing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public void isInterface(TypeElement element, ElementValidation valid) {
}
}

public void isNotInterface(TypeElement element, ElementValidation valid) {
if (annotationHelper.isInterface(element)) {
valid.addError("%s cannot be used on an interface");
}
}

public void isTopLevel(TypeElement element, ElementValidation valid) {
if (!annotationHelper.isTopLevel(element)) {
valid.addError("%s can only be used on a top level type");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public EBeanHolder createGeneratedClassHolder(AndroidAnnotationsEnvironment envi
public void validate(Element element, ElementValidation valid) {
super.validate(element, valid);

validatorHelper.isNotInterface((TypeElement) element, valid);

validatorHelper.isNotPrivate(element, valid);

validatorHelper.isAbstractOrHasEmptyOrContextConstructor(element, valid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public void activitySubclassInManifestCompiles() {
SomeGenericBeanExt.class));
}

@Test
public void eBeanOnInterfaceDoesNotCompile() {
assertCompilationError(compileFiles(InterfaceWithEBean.class));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright (C) 2010-2015 eBusiness Information, Excilys Group
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
package org.androidannotations.ebean;

import org.androidannotations.annotations.EBean;

@EBean
public interface InterfaceWithEBean {
}