aboutsummaryrefslogtreecommitdiff
path: root/javatests/dagger/internal/codegen/goldens/AssistedFactoryTest_testMultipleAssistedFactoryInDifferentComponents_FAST_INIT_MODE_test.DaggerMyComponent
blob: 315ebc43cc895dad6f849c5743a6228e05169be8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package test;

import dagger.internal.DaggerGenerated;
import dagger.internal.SingleCheck;
import javax.annotation.processing.Generated;
import javax.inject.Provider;

@DaggerGenerated
@Generated(
    value = "dagger.internal.codegen.ComponentProcessor",
    comments = "https://dagger.dev"
)
@SuppressWarnings({
    "unchecked",
    "rawtypes",
    "KotlinInternal",
    "KotlinInternalInJava"
})
final class DaggerMyComponent {
  private DaggerMyComponent() {
  }

  public static Builder builder() {
    return new Builder();
  }

  public static MyComponent create() {
    return new Builder().build();
  }

  static final class Builder {
    private Builder() {
    }

    public MyComponent build() {
      return new MyComponentImpl();
    }
  }

  private static final class MySubcomponentImpl implements MySubcomponent {
    private final MyComponentImpl myComponentImpl;

    private final MySubcomponentImpl mySubcomponentImpl = this;

    private Provider<MySubcomponentAssistedFactory> mySubcomponentAssistedFactoryProvider;

    private MySubcomponentImpl(MyComponentImpl myComponentImpl) {
      this.myComponentImpl = myComponentImpl;

      initialize();

    }

    @SuppressWarnings("unchecked")
    private void initialize() {
      this.mySubcomponentAssistedFactoryProvider = SingleCheck.provider(new SwitchingProvider<MySubcomponentAssistedFactory>(myComponentImpl, mySubcomponentImpl, 0));
    }

    @Override
    public MySubcomponentAssistedFactory mySubcomponentAssistedFactory() {
      return mySubcomponentAssistedFactoryProvider.get();
    }

    private static final class SwitchingProvider<T> implements Provider<T> {
      private final MyComponentImpl myComponentImpl;

      private final MySubcomponentImpl mySubcomponentImpl;

      private final int id;

      SwitchingProvider(MyComponentImpl myComponentImpl, MySubcomponentImpl mySubcomponentImpl,
          int id) {
        this.myComponentImpl = myComponentImpl;
        this.mySubcomponentImpl = mySubcomponentImpl;
        this.id = id;
      }

      @SuppressWarnings("unchecked")
      @Override
      public T get() {
        switch (id) {
          case 0: // test.MySubcomponentAssistedFactory 
          return (T) new MySubcomponentAssistedFactory() {
            @Override
            public MyAssistedClass create(Bar bar, Foo foo) {
              return new MyAssistedClass(foo, new Baz(), bar);
            }
          };

          default: throw new AssertionError(id);
        }
      }
    }
  }

  private static final class MyComponentImpl implements MyComponent {
    private final MyComponentImpl myComponentImpl = this;

    private Provider<MyComponentAssistedFactory> myComponentAssistedFactoryProvider;

    private MyComponentImpl() {

      initialize();

    }

    @SuppressWarnings("unchecked")
    private void initialize() {
      this.myComponentAssistedFactoryProvider = SingleCheck.provider(new SwitchingProvider<MyComponentAssistedFactory>(myComponentImpl, 0));
    }

    @Override
    public MyComponentAssistedFactory myComponentAssistedFactory() {
      return myComponentAssistedFactoryProvider.get();
    }

    @Override
    public MySubcomponent mySubcomponent() {
      return new MySubcomponentImpl(myComponentImpl);
    }

    private static final class SwitchingProvider<T> implements Provider<T> {
      private final MyComponentImpl myComponentImpl;

      private final int id;

      SwitchingProvider(MyComponentImpl myComponentImpl, int id) {
        this.myComponentImpl = myComponentImpl;
        this.id = id;
      }

      @SuppressWarnings("unchecked")
      @Override
      public T get() {
        switch (id) {
          case 0: // test.MyComponentAssistedFactory 
          return (T) new MyComponentAssistedFactory() {
            @Override
            public MyAssistedClass create(Bar bar, Foo foo) {
              return new MyAssistedClass(foo, new Baz(), bar);
            }
          };

          default: throw new AssertionError(id);
        }
      }
    }
  }
}