1aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins/** 2aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * Copyright (C) 2008 Google Inc. 3aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * 4aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * Licensed under the Apache License, Version 2.0 (the "License"); 5aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * you may not use this file except in compliance with the License. 6aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * You may obtain a copy of the License at 7aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * 8aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * http://www.apache.org/licenses/LICENSE-2.0 9aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * 10aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * Unless required by applicable law or agreed to in writing, software 11aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * distributed under the License is distributed on an "AS IS" BASIS, 12aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * See the License for the specific language governing permissions and 14aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * limitations under the License. 15aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins */ 16aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins 17aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkinspackage com.google.inject.grapher; 18aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins 19b71955639ab617e0a4115b1439c8b9982227a018sberlinimport com.google.common.base.Objects; 20aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkinsimport java.lang.reflect.Member; 21b71955639ab617e0a4115b1439c8b9982227a018sberlinimport java.util.Collection; 22aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins 23aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins/** 246b3086dc7ca0b0f9d664fb7cc1f4664e4a4df640Sam Berlin * Node for types that have {@link com.google.inject.spi.Dependency}s and are 256b3086dc7ca0b0f9d664fb7cc1f4664e4a4df640Sam Berlin * bound to {@link InterfaceNode}s. These nodes will often have fields for 266b3086dc7ca0b0f9d664fb7cc1f4664e4a4df640Sam Berlin * {@link Member}s that are {@link com.google.inject.spi.InjectionPoint}s. 27b71955639ab617e0a4115b1439c8b9982227a018sberlin * 28aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * @see DependencyEdge 29aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins * @author phopkins@gmail.com (Pete Hopkins) 30646e1742c047dc9a768f2bc065b33e9b5ab49006cgdecker * @since 4.0 (since 2.0 as an interface) 31aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins */ 32b71955639ab617e0a4115b1439c8b9982227a018sberlinpublic class ImplementationNode extends Node { 33b71955639ab617e0a4115b1439c8b9982227a018sberlin private final Collection<Member> members; 34aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins 35b71955639ab617e0a4115b1439c8b9982227a018sberlin public ImplementationNode(NodeId id, Object source, Collection<Member> members) { 36b71955639ab617e0a4115b1439c8b9982227a018sberlin super(id, source); 37b71955639ab617e0a4115b1439c8b9982227a018sberlin this.members = members; 38b71955639ab617e0a4115b1439c8b9982227a018sberlin } 39b71955639ab617e0a4115b1439c8b9982227a018sberlin 40b71955639ab617e0a4115b1439c8b9982227a018sberlin public Collection<Member> getMembers() { 41b71955639ab617e0a4115b1439c8b9982227a018sberlin return members; 42b71955639ab617e0a4115b1439c8b9982227a018sberlin } 43aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins 44b71955639ab617e0a4115b1439c8b9982227a018sberlin @Override public boolean equals(Object obj) { 45b71955639ab617e0a4115b1439c8b9982227a018sberlin if (!(obj instanceof ImplementationNode)) { 46b71955639ab617e0a4115b1439c8b9982227a018sberlin return false; 47b71955639ab617e0a4115b1439c8b9982227a018sberlin } 48b71955639ab617e0a4115b1439c8b9982227a018sberlin ImplementationNode other = (ImplementationNode) obj; 49b71955639ab617e0a4115b1439c8b9982227a018sberlin return super.equals(other) && Objects.equal(members, other.members); 50b71955639ab617e0a4115b1439c8b9982227a018sberlin } 51b71955639ab617e0a4115b1439c8b9982227a018sberlin 52b71955639ab617e0a4115b1439c8b9982227a018sberlin @Override public int hashCode() { 53b71955639ab617e0a4115b1439c8b9982227a018sberlin return 31 * super.hashCode() + Objects.hashCode(members); 54b71955639ab617e0a4115b1439c8b9982227a018sberlin } 55b71955639ab617e0a4115b1439c8b9982227a018sberlin 56b71955639ab617e0a4115b1439c8b9982227a018sberlin @Override public String toString() { 57b71955639ab617e0a4115b1439c8b9982227a018sberlin return "ImplementationNode{id=" + getId() + " source=" + getSource() 58b71955639ab617e0a4115b1439c8b9982227a018sberlin + " members=" + members + "}"; 59b71955639ab617e0a4115b1439c8b9982227a018sberlin } 60aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins 61b71955639ab617e0a4115b1439c8b9982227a018sberlin @Override public Node copy(NodeId id) { 62b71955639ab617e0a4115b1439c8b9982227a018sberlin return new ImplementationNode(id, getSource(), getMembers()); 63aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins } 64aff72e051a38af75e8a6bce59d1a9a4b760d914bphopkins} 65