Search in sources :

Example 1 with Component

use of dagger.Component in project tiger by google.

the class TigerDaggerGeneratorProcessor method getComponentDependencies.

/**
   * Returns dependency components of the give component, empty set if none.
   */
private Set<TypeElement> getComponentDependencies(TypeElement component) {
    Set<TypeElement> result = new HashSet<>();
    AnnotationMirror componentAnnotationMirror = Preconditions.checkNotNull(Utils.getAnnotationMirror(component, Component.class), String.format("@Component not found for %s", component));
    AnnotationValue dependenciesAnnotationValue = Utils.getAnnotationValue(componentAnnotationMirror, "dependencies");
    if (dependenciesAnnotationValue == null) {
        return result;
    }
    List<? extends AnnotationValue> dependencies = (List<? extends AnnotationValue>) dependenciesAnnotationValue.getValue();
    for (AnnotationValue dependency : dependencies) {
        result.add((TypeElement) ((DeclaredType) dependency.getValue()).asElement());
    }
    return result;
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) TypeElement(javax.lang.model.element.TypeElement) AnnotationValue(javax.lang.model.element.AnnotationValue) ArrayList(java.util.ArrayList) List(java.util.List) Component(dagger.Component) HashSet(java.util.HashSet) DeclaredType(javax.lang.model.type.DeclaredType)

Aggregations

Component (dagger.Component)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 AnnotationMirror (javax.lang.model.element.AnnotationMirror)1 AnnotationValue (javax.lang.model.element.AnnotationValue)1 TypeElement (javax.lang.model.element.TypeElement)1 DeclaredType (javax.lang.model.type.DeclaredType)1