• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 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 com.google.auto.factory.AutoFactory;
19 import java.util.List;
20 
21 final class FactoryImplementingCreateMethod {
22 
23   interface Interface {}
24 
25   interface FactoryInterfaceWithCreateMethod {
create()26     Interface create();
27 
create(int a)28     Interface create(int a);
29 
create(List<Integer> generic)30     Interface create(List<Integer> generic);
31   }
32 
33   @AutoFactory(implementing = FactoryInterfaceWithCreateMethod.class)
34   static class ConcreteClass implements Interface {
35     // Will generate a method with a signature that matches one from the interface.
ConcreteClass()36     ConcreteClass() {}
37 
38     // Will generate a method with a signature that matches one from the interface.
ConcreteClass(int aDifferentArgumentName)39     ConcreteClass(int aDifferentArgumentName) {}
40 
41     // Will generate a method with a signature that matches one from the interface.
ConcreteClass(List<Integer> genericWithDifferentArgumentName)42     ConcreteClass(List<Integer> genericWithDifferentArgumentName) {}
43 
ConcreteClass(int a, boolean b)44     ConcreteClass(int a, boolean b) {}
45   }
46 }
47