public List<Facet> facets() {
    if (cachedFacets != null) {
      return cachedFacets;
    }

    final CriteriaRepositoryMirror annotation = annotation();
    final List<Facet> facets = new ArrayList<>();

    for (TypeMirror mirror: annotation.facetsMirror()) {
      final Element element = types.asElement(mirror);
      if (MoreElements.isType(element)) {
        final TypeElement type = isEclipseImplementation ? elements.getTypeElement(MoreElements.asType(element).getQualifiedName()) : MoreElements.asType(element);
        final FacetConsumer facetConsumer = new FacetConsumer(facets, type);
        for (TypeMirror iface: type.getInterfaces()) {
          facetConsumer.consume(iface);
        }
      }
    }
    cachedFacets = ImmutableList.copyOf(facets);
    return cachedFacets;
  }
Repository model and builder. Traverses {@code javax.lang.model} API to generate
repository interfaces and methods and expose them in template engine.

TODO: This code is currently a mess and needs cleanup.
value-processor/src/org/immutables/value/processor/meta/RepositoryModel.java