@Override
    public void consume(TypeMirror iface) {
      if (!isFacet(iface)) {
        return;
      }

      final TypeElement ifaceElement = MoreElements.asType(types.asElement(iface));
      final String name = nextName(ifaceElement);
      // convert Writable<T> into Writable<Person>
      final DeclaredType fieldType = types.getDeclaredType(typed, RepositoryModel.this.element.asType());

      final List<ExecutableElement> constructors = ElementFilter.constructorsIn(elements.getAllMembers(typed));
      final CodeBlock block;
      if (!constructors.isEmpty()) {
        final List<String> params = new ArrayList<>();
        // only one constructor expected
        ExecutableElement ctor = constructors.get(0);
        for(VariableElement variable:ctor.getParameters()) {
          TypeMirror varType = variable.asType();
          if (types.isSubtype(varType, types.erasure(elements.getTypeElement(Class.class.getCanonicalName()).asType()))) {
            // inject entity class
            params.add(RepositoryModel.this.type.typeDocument().toString() + ".class");
          } else if (types.isSubtype(varType, elements.getTypeElement(BACKEND).asType())) {
            // inject backend
            params.add("backend");
          } else if (types.isSubtype(varType, elements.getTypeElement(SESSION).asType())) {
            params.add("session");
          }
        }

        block = new CodeBlock(String.format("this.%s = new %s(%s)", name, fieldType, Joiner.on(", ").join(params)));
      } else {
        block = new CodeBlock("");
      }

      ImmutableFacet.Builder facet = ImmutableFacet.builder();
      // figure out list of interface methods to implement from eg. Writable
      final DeclaredType interfaceType = types.getDeclaredType(ifaceElement, RepositoryModel.this.element.asType());
      final List<ExecutableElement> ifaceMethods = ElementFilter.methodsIn(elements.getAllMembers(MoreElements.asType(interfaceType.asElement())));
      final List<ExecutableElement> objectMethods = ElementFilter.methodsIn(elements.getAllMembers(MoreElements.asType(elements.getTypeElement(Object.class.getCanonicalName()))));
      ifaceMethods.removeAll(objectMethods);

      for (ExecutableElement exec : ifaceMethods) {
        if (isEclipseImplementation && exec.isDefault()) {
          // Eclipse ECJ doesn't resolve (as in Types.asMemberOf) correctly default methods.
          // Skip default methods in Eclipse compiler.
          continue;
        }
        ExecutableType type1 = MoreTypes.asExecutable(types.asMemberOf(interfaceType, exec));
        facet.addMethods(new DelegateMethod(type1, exec, name));
      }

      facet.name(name)
              .interfaceType(interfaceType)
              .fieldType(fieldType)
              .constructor(block)
              .build();

      facets.add(facet.build());
    }
Variable name based on facet element
value-processor/src/org/immutables/value/processor/meta/RepositoryModel.java