View Javadoc

1   // ========================================================================
2   // Copyright (c) Webtide LLC
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   //
8   // The Eclipse Public License is available at 
9   // http://www.eclipse.org/legal/epl-v10.html
10  //
11  // The Apache License v2.0 is available at
12  // http://www.apache.org/licenses/LICENSE-2.0.txt
13  //
14  // You may elect to redistribute this code under either of these licenses. 
15  // ========================================================================
16  package org.eclipse.jetty.deploy.graph;
17  
18  /**
19   * Basic Graph Edge
20   */
21  public final class Edge
22  {
23      private Node _from;
24      private Node _to;
25  
26      public Edge(Node from, Node to)
27      {
28          if (from==null || to==null || from==to)
29              throw new IllegalArgumentException("from "+from+" to "+to);
30          _from = from;
31          _to = to;
32      }
33  
34      @Override
35      public int hashCode()
36      {
37          return _from.hashCode() ^ _to.hashCode();
38      }
39  
40      @Override
41      public boolean equals(Object obj)
42      {
43          if (this == obj)
44              return true;
45          if (obj == null)
46              return false;
47          if (getClass() != obj.getClass())
48              return false;
49          Edge other = (Edge)obj;
50          if (_from == null)
51          {
52              if (other._from != null)
53                  return false;
54          }
55          else if (!_from.equals(other._from))
56              return false;
57          if (_to == null)
58          {
59              if (other._to != null)
60                  return false;
61          }
62          else if (!_to.equals(other._to))
63              return false;
64          return true;
65      }
66  
67      public Node getFrom()
68      {
69          return _from;
70      }
71  
72      public Node getTo()
73      {
74          return _to;
75      }
76      
77      @Override
78      public String toString()
79      {
80          return _from+"->"+_to;
81      }
82  }