View Javadoc

1   /*
2    * Copyright 2004 Ronald Blaschke.
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  package org.rblasch.convert.graph;
17  
18  public final class Connection {
19      private final Vertex start, end;
20      private final Edge edge;
21  
22      public Connection(final Vertex start, final Edge edge, final Vertex end) {
23          this.start = start;
24          this.edge = edge;
25          this.end = end;
26      }
27  
28      public Vertex getStart() {
29          return start;
30      }
31  
32      public Edge getEdge() {
33          return edge;
34      }
35  
36      public Vertex getEnd() {
37          return end;
38      }
39  
40      public String toString() {
41          return start + " " + edge + " " + end;
42      }
43  
44      // generated
45      public boolean equals(final Object o) {
46          if (this == o) return true;
47          if (!(o instanceof Connection)) return false;
48  
49          final Connection connection = (Connection) o;
50  
51          if (!edge.equals(connection.edge)) return false;
52          if (!end.equals(connection.end)) return false;
53          if (!start.equals(connection.start)) return false;
54  
55          return true;
56      }
57  
58      public int hashCode() {
59          int result;
60          result = start.hashCode();
61          result = 29 * result + end.hashCode();
62          result = 29 * result + edge.hashCode();
63          return result;
64      }
65  }