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#MULTIBOUND_MAP}. */ 30 @CheckReturnValue 31 @AutoValue 32 public abstract class MultiboundMapBinding extends ContributionBinding { 33 @Override kind()34 public BindingKind kind() { 35 return BindingKind.MULTIBOUND_MAP; 36 } 37 38 @Override contributionType()39 public ContributionType contributionType() { 40 return ContributionType.UNIQUE; 41 } 42 43 @Override nullability()44 public Nullability nullability() { 45 return Nullability.NOT_NULLABLE; 46 } 47 48 @Override toBuilder()49 public abstract Builder toBuilder(); 50 51 @Memoized 52 @Override hashCode()53 public abstract int hashCode(); 54 55 // TODO(ronshapiro,dpb): simplify the equality semantics 56 @Override equals(Object obj)57 public abstract boolean equals(Object obj); 58 builder()59 static Builder builder() { 60 return new AutoValue_MultiboundMapBinding.Builder(); 61 } 62 63 /** A {@link MultiboundMapBinding} builder. */ 64 @AutoValue.Builder 65 abstract static class Builder 66 extends ContributionBinding.Builder<MultiboundMapBinding, Builder> { dependencies(ImmutableSet<DependencyRequest> dependencies)67 abstract Builder dependencies(ImmutableSet<DependencyRequest> dependencies); 68 optionalBindingType(Optional<BindingType> optionalBindingType)69 abstract Builder optionalBindingType(Optional<BindingType> optionalBindingType); 70 } 71 } 72