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