View Javadoc

1   /* This file is part of the project "Hilbert II" - http://www.qedeq.org" target="alexandria_uri">http://www.qedeq.org
2    *
3    * Copyright 2000-2014,  Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   * GNU General Public License for more details.
14   */
15  
16  package org.qedeq.kernel.se.common;
17  
18  import org.qedeq.base.utility.EqualsUtility;
19  
20  /**
21   * Rule key, describing a certain version of a rule.
22   *
23   * @author  Michael Meyling
24   */
25  public final class RuleKey {
26  
27      /** Rule name. */
28      private String name;
29  
30      /** Rule version. */
31      private String version;
32  
33      /**
34       * Constructor.
35       *
36       * @param   name        Rule name.
37       * @param   version     Rule argument number.
38       */
39      public RuleKey(final String name, final String version) {
40          this.name = name;
41          this.version = version;
42      }
43  
44      /**
45       * Get rule name.
46       *
47       * @return  Rule name.
48       */
49      public String getName() {
50          return name;
51      }
52  
53      /**
54       * Get rule version.
55       *
56       * @return  Rule version.
57       */
58      public String getVersion() {
59          return version;
60      }
61  
62      public int hashCode() {
63          return (getName() != null ? getName().hashCode() : 0)
64              ^ (getVersion() != null ? getVersion().hashCode() : 0);
65      }
66  
67      public boolean equals(final Object obj) {
68          if (!(obj instanceof RuleKey)) {
69              return false;
70          }
71          final RuleKey other = (RuleKey) obj;
72          return EqualsUtility.equals(getName(), other.getName())
73              && EqualsUtility.equals(getVersion(), other.getVersion());
74      }
75  
76      public String toString() {
77          return getName() + " [" + getVersion() + "]";
78      }
79  
80  
81  }