View Javadoc

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