001package io.dinject.core;
002
003import java.util.List;
004
005/**
006 * Factory for creating Builder instances.
007 * <p>
008 * These Builders are typically used by generated code (Java annotation processing - dinject-generator).
009 */
010public class BuilderFactory {
011
012  /**
013   * Create the root level Builder.
014   *
015   * @param suppliedBeans The list of beans (typically test doubles) supplied when building the context.
016   * @param enrichBeans   The list of classes we want to have with mockito spy enhancement
017   */
018  public static Builder newRootBuilder(List<SuppliedBean> suppliedBeans, List<EnrichBean> enrichBeans) {
019
020    if (suppliedBeans.isEmpty() && enrichBeans.isEmpty()) {
021      // simple case, no mocks or spies
022      return new DBuilder();
023    }
024    return new DBuilderExtn(suppliedBeans, enrichBeans);
025  }
026
027  /**
028   * Create a Builder for the named context (module).
029   *
030   * @param name      the name of the module / bean context
031   * @param provides  the module features this module provides
032   * @param dependsOn the names of modules this module is depends on.
033   */
034  public static Builder newBuilder(String name, String[] provides, String[] dependsOn) {
035    return new DBuilder(name, provides, dependsOn);
036  }
037
038  private BuilderFactory(){
039    // hide
040  }
041}