• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package tests;
17 
18 import javax.annotation.processing.Generated;
19 import javax.inject.Inject;
20 import javax.inject.Provider;
21 
22 @Generated(
23     value = "com.google.auto.factory.processor.AutoFactoryProcessor",
24     comments = "https://github.com/google/auto/tree/main/factory"
25     )
26 final class ParameterAnnotationsFactory {
27   private final Provider<@ParameterAnnotations.NullableType String> fooProvider;
28 
29   @Inject
ParameterAnnotationsFactory(Provider<@ParameterAnnotations.NullableType String> fooProvider)30   ParameterAnnotationsFactory(Provider<@ParameterAnnotations.NullableType String> fooProvider) {
31     this.fooProvider = checkNotNull(fooProvider, 1, 1);
32   }
33 
create( @arameterAnnotations.NullableParameter Integer bar, @ParameterAnnotations.Nullable Long baz, @ParameterAnnotations.NullableType Thread buh, @ParameterAnnotations.NullableParameterAndType String quux)34   ParameterAnnotations create(
35       @ParameterAnnotations.NullableParameter Integer bar,
36       @ParameterAnnotations.Nullable Long baz,
37       @ParameterAnnotations.NullableType Thread buh,
38       @ParameterAnnotations.NullableParameterAndType String quux) {
39     return new ParameterAnnotations(
40         checkNotNull(fooProvider.get(), 1, 5),
41         checkNotNull(bar, 2, 5),
42         baz,
43         checkNotNull(buh, 4, 5),
44         checkNotNull(quux, 5, 5));
45   }
46 
checkNotNull(T reference, int argumentNumber, int argumentCount)47   private static <T> T checkNotNull(T reference, int argumentNumber, int argumentCount) {
48     if (reference == null) {
49       throw new NullPointerException(
50           "@AutoFactory method argument is null but is not marked @Nullable. Argument "
51               + argumentNumber
52               + " of "
53               + argumentCount);
54     }
55     return reference;
56   }
57 }
58