• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Dagger Authors.
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 
17 package dagger.internal.codegen.validation;
18 
19 import static com.google.common.collect.Maps.uniqueIndex;
20 
21 import com.google.common.collect.ImmutableMap;
22 import dagger.Binds;
23 import dagger.Module;
24 import dagger.Provides;
25 import dagger.multibindings.IntoSet;
26 import java.lang.annotation.Annotation;
27 import java.util.Set;
28 
29 /**
30  * Binds each {@link BindingMethodValidator} into a map, keyed by {@link
31  * BindingMethodValidator#methodAnnotation()}.
32  */
33 @Module
34 public interface BindingMethodValidatorsModule {
35   @Provides
indexValidators( Set<BindingMethodValidator> validators)36   static ImmutableMap<Class<? extends Annotation>, BindingMethodValidator> indexValidators(
37       Set<BindingMethodValidator> validators) {
38     return uniqueIndex(validators, BindingMethodValidator::methodAnnotation);
39   }
40 
41   @Binds
42   @IntoSet
provides(ProvidesMethodValidator validator)43   BindingMethodValidator provides(ProvidesMethodValidator validator);
44 
45   @Binds
46   @IntoSet
produces(ProducesMethodValidator validator)47   BindingMethodValidator produces(ProducesMethodValidator validator);
48 
49   @Binds
50   @IntoSet
binds(BindsMethodValidator validator)51   BindingMethodValidator binds(BindsMethodValidator validator);
52 
53   @Binds
54   @IntoSet
multibinds(MultibindsMethodValidator validator)55   BindingMethodValidator multibinds(MultibindsMethodValidator validator);
56 
57   @Binds
58   @IntoSet
bindsOptionalOf(BindsOptionalOfMethodValidator validator)59   BindingMethodValidator bindsOptionalOf(BindsOptionalOfMethodValidator validator);
60 }
61