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.common.base.Objects; 20import java.lang.reflect.Member; 21import java.util.Collection; 22 23/** 24 * Node for types that have {@link com.google.inject.spi.Dependency}s and are 25 * bound to {@link InterfaceNode}s. These nodes will often have fields for 26 * {@link Member}s that are {@link com.google.inject.spi.InjectionPoint}s. 27 * 28 * @see DependencyEdge 29 * @author phopkins@gmail.com (Pete Hopkins) 30 * @since 4.0 (since 2.0 as an interface) 31 */ 32public class ImplementationNode extends Node { 33 private final Collection<Member> members; 34 35 public ImplementationNode(NodeId id, Object source, Collection<Member> members) { 36 super(id, source); 37 this.members = members; 38 } 39 40 public Collection<Member> getMembers() { 41 return members; 42 } 43 44 @Override public boolean equals(Object obj) { 45 if (!(obj instanceof ImplementationNode)) { 46 return false; 47 } 48 ImplementationNode other = (ImplementationNode) obj; 49 return super.equals(other) && Objects.equal(members, other.members); 50 } 51 52 @Override public int hashCode() { 53 return 31 * super.hashCode() + Objects.hashCode(members); 54 } 55 56 @Override public String toString() { 57 return "ImplementationNode{id=" + getId() + " source=" + getSource() 58 + " members=" + members + "}"; 59 } 60 61 @Override public Node copy(NodeId id) { 62 return new ImplementationNode(id, getSource(), getMembers()); 63 } 64} 65