1 /*
2  * Copyright (C) 2018 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.model;
18 
19 import com.google.auto.value.AutoValue;
20 import com.google.auto.value.extension.memoized.Memoized;
21 import com.google.common.collect.ImmutableSetMultimap;
22 import com.google.common.graph.ImmutableNetwork;
23 import com.google.common.graph.Network;
24 import dagger.model.BindingGraph.Edge;
25 import dagger.model.BindingGraph.MissingBinding;
26 import dagger.model.BindingGraph.Node;
27 
28 /**
29  * Exposes package-private constructors to the {@code dagger.internal.codegen} package. <em>This
30  * class should only be used in the Dagger implementation and is not part of any documented
31  * API.</em>
32  */
33 public final class BindingGraphProxies {
34 
35   @AutoValue
36   abstract static class BindingGraphImpl extends BindingGraph {
37     @Override
38     @Memoized
nodesByClass()39     public ImmutableSetMultimap<Class<? extends Node>, ? extends Node> nodesByClass() {
40       return super.nodesByClass();
41     }
42   }
43 
44   @AutoValue
45   abstract static class MissingBindingImpl extends MissingBinding {
46     @Memoized
47     @Override
hashCode()48     public abstract int hashCode();
49 
50     @Override
equals(Object o)51     public abstract boolean equals(Object o);
52   }
53 
54   /** Creates a new {@link BindingGraph}. */
bindingGraph(Network<Node, Edge> network, boolean isFullBindingGraph)55   public static BindingGraph bindingGraph(Network<Node, Edge> network, boolean isFullBindingGraph) {
56     return new AutoValue_BindingGraphProxies_BindingGraphImpl(
57         ImmutableNetwork.copyOf(network), isFullBindingGraph);
58   }
59 
60   /** Creates a new {@link MissingBinding}. */
missingBindingNode(ComponentPath component, Key key)61   public static MissingBinding missingBindingNode(ComponentPath component, Key key) {
62     return new AutoValue_BindingGraphProxies_MissingBindingImpl(component, key);
63   }
64 
BindingGraphProxies()65   private BindingGraphProxies() {}
66 }
67