Search in sources :

Example 41 with ExecutableElement

use of javax.lang.model.element.ExecutableElement in project androidannotations by androidannotations.

the class AbstractOttoHandler method validate.

@Override
public void validate(Element element, ElementValidation valid) {
    if (!annotationHelper.enclosingElementHasEnhancedComponentAnnotation(element)) {
        // do nothing when otto annotations are used in non-enhanced classes
        return;
    }
    ExecutableElement executableElement = (ExecutableElement) element;
    validateReturnType(executableElement, valid);
    validatorHelper.isPublic(element, valid);
    validatorHelper.doesntThrowException(executableElement, valid);
    validatorHelper.isNotFinal(element, valid);
    getParamValidator().validate(executableElement, valid);
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement)

Example 42 with ExecutableElement

use of javax.lang.model.element.ExecutableElement in project androidannotations by androidannotations.

the class ValidatorParameterHelperTest method inOrderFail3.

@Test
public void inOrderFail3() throws Exception {
    ExecutableElement executableElement = createMethod(boolean.class, boolean.class, long.class, Bundle.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    //
    validator.inOrder().type(boolean.class.getName()).multiple().type(long.class.getName()).optional().type(int.class.getName()).optional().validate(executableElement, valid);
    assertFalse(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Example 43 with ExecutableElement

use of javax.lang.model.element.ExecutableElement in project androidannotations by androidannotations.

the class ValidatorParameterHelperTest method extendsViewType.

@Test
public void extendsViewType() throws Exception {
    ExecutableElement executableElement = createMethod(TextView.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    validator.extendsType(CanonicalNameConstants.VIEW).validate(executableElement, valid);
    assertTrue(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Example 44 with ExecutableElement

use of javax.lang.model.element.ExecutableElement in project androidannotations by androidannotations.

the class ValidatorParameterHelperTest method inOrderSuccess.

@Test
public void inOrderSuccess() throws Exception {
    ExecutableElement executableElement = createMethod(boolean.class, int.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    //
    validator.inOrder().type(//
    boolean.class.getName()).type(long.class.getName()).optional().type(//
    int.class.getName()).validate(executableElement, valid);
    assertTrue(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Example 45 with ExecutableElement

use of javax.lang.model.element.ExecutableElement in project androidannotations by androidannotations.

the class ValidatorParameterHelperTest method inOrderFail4.

@Test
public void inOrderFail4() throws Exception {
    ExecutableElement executableElement = createMethod(int.class, long.class, boolean.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    //
    validator.inOrder().type(boolean.class.getName()).optional().type(long.class.getName()).optional().type(int.class.getName()).optional().validate(executableElement, valid);
    assertFalse(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Aggregations

ExecutableElement (javax.lang.model.element.ExecutableElement)345 TypeElement (javax.lang.model.element.TypeElement)158 TypeMirror (javax.lang.model.type.TypeMirror)97 VariableElement (javax.lang.model.element.VariableElement)85 Element (javax.lang.model.element.Element)72 Test (org.junit.Test)41 GeneratedExecutableElement (com.google.devtools.j2objc.types.GeneratedExecutableElement)32 DeclaredType (javax.lang.model.type.DeclaredType)31 ArrayList (java.util.ArrayList)26 JBlock (com.helger.jcodemodel.JBlock)25 JInvocation (com.helger.jcodemodel.JInvocation)20 MethodDeclaration (com.google.devtools.j2objc.ast.MethodDeclaration)18 JVar (com.helger.jcodemodel.JVar)18 Map (java.util.Map)18 HashSet (java.util.HashSet)17 IJExpression (com.helger.jcodemodel.IJExpression)16 ElementValidation (org.androidannotations.ElementValidation)15 Block (com.google.devtools.j2objc.ast.Block)13 JMethod (com.helger.jcodemodel.JMethod)13 Elements (javax.lang.model.util.Elements)13