1 /* 2 * Copyright (C) 2024 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.binding; 18 19 import com.google.auto.value.AutoValue; 20 import com.google.auto.value.extension.memoized.Memoized; 21 import com.google.common.collect.ImmutableSet; 22 import com.google.errorprone.annotations.CheckReturnValue; 23 import dagger.internal.codegen.base.ContributionType; 24 import dagger.internal.codegen.model.BindingKind; 25 import dagger.internal.codegen.model.DependencyRequest; 26 import dagger.internal.codegen.xprocessing.Nullability; 27 import java.util.Optional; 28 29 /** A binding for a {@link BindingKind#COMPONENT_DEPENDENCY}. */ 30 @CheckReturnValue 31 @AutoValue 32 public abstract class ComponentDependencyBinding extends ContributionBinding { 33 @Override kind()34 public BindingKind kind() { 35 return BindingKind.COMPONENT_DEPENDENCY; 36 } 37 38 @Override optionalBindingType()39 public Optional<BindingType> optionalBindingType() { 40 return Optional.of(BindingType.PROVISION); 41 } 42 43 @Override contributionType()44 public ContributionType contributionType() { 45 return ContributionType.UNIQUE; 46 } 47 48 @Override nullability()49 public Nullability nullability() { 50 return Nullability.NOT_NULLABLE; 51 } 52 53 @Override dependencies()54 public ImmutableSet<DependencyRequest> dependencies() { 55 return ImmutableSet.of(); 56 } 57 58 @Override toBuilder()59 public abstract Builder toBuilder(); 60 61 @Memoized 62 @Override hashCode()63 public abstract int hashCode(); 64 65 // TODO(ronshapiro,dpb): simplify the equality semantics 66 @Override equals(Object obj)67 public abstract boolean equals(Object obj); 68 builder()69 static Builder builder() { 70 return new AutoValue_ComponentDependencyBinding.Builder(); 71 } 72 73 /** A {@link ComponentDependencyBinding} builder. */ 74 @AutoValue.Builder 75 abstract static class Builder 76 extends ContributionBinding.Builder<ComponentDependencyBinding, Builder> {} 77 } 78