1 /* 2 * Copyright (C) 2015 Google, Inc. 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 test.builder; 17 18 import dagger.Component; 19 20 @Component( 21 modules = {StringModule.class, IntModuleIncludingDoubleAndFloat.class, LongModule.class}, 22 dependencies = DepComponent.class) 23 abstract class TestComponentWithBuilderAbstractClass { 24 25 static Builder builder() { 26 return DaggerTestComponentWithBuilderAbstractClass.builder(); 27 } 28 29 abstract String s(); 30 abstract int i(); 31 abstract long l(); 32 abstract float f(); 33 abstract double d(); 34 35 36 static abstract class SharedBuilder { 37 // Make sure we use the overriding signature. 38 abstract Object build(); 39 40 Object stringModule(@SuppressWarnings("unused") StringModule stringModule) { 41 return null; 42 } 43 44 SharedBuilder ignoredLongModule(@SuppressWarnings("unused") LongModule longModule) { 45 return null; 46 } 47 48 } 49 50 @Component.Builder 51 static abstract class Builder extends SharedBuilder { 52 @Override abstract TestComponentWithBuilderAbstractClass build(); // Narrowing return type 53 @Override abstract Builder stringModule(StringModule stringModule); // Make abstract & narrow 54 abstract Builder intModule(IntModuleIncludingDoubleAndFloat intModule); 55 abstract void doubleModule(DoubleModule doubleModule); // Module w/o args 56 abstract void depComponent(DepComponent depComponent); 57 58 Builder ignoredIntModule( 59 @SuppressWarnings("unused") IntModuleIncludingDoubleAndFloat intModule) { 60 return null; 61 } 62 63 // Note we're missing LongModule & FloatModule -- they/re implicit 64 } 65 } 66