DependencyEdge.java revision 53664a7f17492bd0c3c4728df61679147907dd18
1/**
2 * Copyright (C) 2008 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
17package com.google.inject.grapher;
18
19import com.google.inject.internal.Nullable;
20import com.google.inject.spi.InjectionPoint;
21
22/**
23 * Interface for an edge from a class or {@link InjectionPoint} to the
24 * interface node that will satisfy the dependency.
25 *
26 * @author phopkins@gmail.com (Pete Hopkins)
27 *
28 * @param <K> The type for node IDs.
29 */
30public interface DependencyEdge<K> {
31  /**
32   * Factory interface for {@link DependencyEdge}s. Renderer implementations
33   * will need to provide an implementation for this.
34   *
35   * @param <K> The type for node IDs.
36   * @param <T> The {@link DependencyEdge} sub-type that this factory provides.
37   */
38  interface Factory<K, T extends DependencyEdge<K>> {
39    /**
40     * Creates a new {@link DependencyEdge} and adds it to the graph.
41     *
42     * @param fromId The ID for the class or instance node that has the
43     *     dependency.
44     * @param fromPoint The point where the dependency will be
45     *     {@literal @}{@link Inject}ed.
46     * @param toId The ID for the interface node that satisfies the dependency.
47     */
48    T newDependencyEdge(K fromId, @Nullable InjectionPoint fromPoint, K toId);
49  }
50}
51