Example #1
1
  private void extractClassIntoMaps(Class type, boolean foundName, Supplier supplier) {

    if (type == null) {
      return;
    }
    String named = null;

    Class superClass = type.getSuperclass();

    Class[] superTypes = type.getInterfaces();

    for (Class superType : superTypes) {
      this.supplierTypeMap.put(superType, supplier);
    }

    while (superClass != Object.class) {
      this.supplierTypeMap.put(superClass, supplier);

      if (!foundName) {
        named = NamedUtils.namedValueForClass(superClass);
        if (named != null) {
          supplierNameMap.put(named, new ProviderInfo(named, type, supplier, null));
          foundName = true;
        }
      }

      superTypes = type.getInterfaces();
      for (Class superType : superTypes) {
        this.supplierTypeMap.put(superType, supplier);
      }
      superClass = superClass.getSuperclass();
    }
  }
Example #2
0
  private void supplierExtraction(ProviderInfo[] suppliers) {
    for (ProviderInfo providerInfo : suppliers) {

      Class<?> type = providerInfo.type();
      /* Get type from value. */
      if (type == null && providerInfo.value() != null) {
        type = providerInfo.value().getClass();
      }
      String named = providerInfo.name();
      Supplier supplier = providerInfo.supplier();

      if (supplier == null) {
        supplier = createSupplier(type, providerInfo.value());
      }

      if (type != null) {

        supplierTypeMap.put(type, supplier);

        /* Named passed in overrides name in class annotation @Named. */
        if (named == null) {

          named = namedValueForClass(type);
        }
      }

      extractClassIntoMaps(type, named != null, supplier);
      if (named != null) {
        supplierNameMap.put(named, new ProviderInfo(named, type, supplier, null));
      }
    }
  }