All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.paypal.butterfly.utilities.conditions.java.AnnotatedWith Maven / Gradle / Ivy

There is a newer version: 3.2.7
Show newest version
package com.paypal.butterfly.utilities.conditions.java;

import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.expr.AnnotationExpr;

import java.util.List;

/**
 * Evaluates if the specified
 * Java class or interface is annotated with the
 * specified annotation.
 *
 * @author facarvalho
 */
public class AnnotatedWith extends AbstractTypeCheck {

    public AnnotatedWith(Class specifiedType) {
        super(specifiedType);
    }

    public AnnotatedWith(String specifiedTypeName) {
        super(specifiedTypeName);
    }

    @Override
    protected String getTypeName(CompilationUnit compilationUnit, int index) {
        List annotations = compilationUnit.getTypes().get(0).getAnnotations();
        return annotations.get(index).getNameAsString();
    }

    @Override
    protected int getNumberOfTypes(CompilationUnit compilationUnit) {
        List annotations = compilationUnit.getTypes().get(0).getAnnotations();
        return annotations.size();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy