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;
17  
18  import org.rblasch.convert.graph.WeightedDirectedEdge;
19  
20  public final class ConverterEdge implements WeightedDirectedEdge {
21      private final MetaConverter converter;
22      private final int weight;
23  
24      public ConverterEdge(final MetaConverter converter, final int weight) {
25          this.converter = converter;
26          this.weight = weight;
27      }
28  
29      public MetaConverter getConverter() {
30          return converter;
31      }
32  
33      public int getWeight() {
34          return weight;
35      }
36  
37      public String toString() {
38          return "-(" + weight + ")->";
39      }
40  
41  
42      // generated
43      public boolean equals(final Object o) {
44          if (this == o) return true;
45          if (!(o instanceof ConverterEdge)) return false;
46  
47          final ConverterEdge converterEdge = (ConverterEdge) o;
48          if (weight != converterEdge.weight) return false;
49          if (!converter.equals(converterEdge.converter)) return false;
50  
51          return true;
52      }
53  
54      public int hashCode() {
55          int result;
56          result = converter.hashCode();
57          result = 29 * result + weight;
58          return result;
59      }
60  }