• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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.functional.producers.multibindings;
18 
19 import com.google.common.collect.ImmutableSet;
20 import dagger.Module;
21 import dagger.Provides;
22 import dagger.functional.producers.multibindings.Qualifiers.EmptyButDeclaredInModule;
23 import dagger.functional.producers.multibindings.Qualifiers.EmptyButDeclaredInModuleAndProducerModule;
24 import dagger.functional.producers.multibindings.Qualifiers.OnlyProvisionMultibindings;
25 import dagger.multibindings.ElementsIntoSet;
26 import dagger.multibindings.IntKey;
27 import dagger.multibindings.IntoMap;
28 import dagger.multibindings.IntoSet;
29 import dagger.multibindings.Multibinds;
30 import dagger.multibindings.StringKey;
31 import java.util.Map;
32 import java.util.Set;
33 
34 @Module
35 abstract class MultibindingModule {
36   @Provides
37   @IntoSet
providedStr()38   static String providedStr() {
39     return "providedStr";
40   }
41 
42   @Provides
43   @ElementsIntoSet
providedStrs()44   static Set<String> providedStrs() {
45     return ImmutableSet.of("providedStr1", "providedStr2");
46   }
47 
48   @Provides
49   @IntoMap
50   @IntKey(3)
providedValueFor3()51   static String providedValueFor3() {
52     return "provided three";
53   }
54 
55   @Multibinds
56   @EmptyButDeclaredInModuleAndProducerModule
emptyButDeclaredInModuleAndProducerModule()57   abstract Map<String, Object> emptyButDeclaredInModuleAndProducerModule();
58 
59   @Multibinds
60   @EmptyButDeclaredInModule
emptyButDeclaredInModule()61   abstract Map<String, Object> emptyButDeclaredInModule();
62 
63   @Provides
64   @IntoMap
65   @StringKey("a")
66   @OnlyProvisionMultibindings
onlyProvisionMultibindings()67   static Object onlyProvisionMultibindings() {
68     return "only multibinding";
69   }
70 }
71