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.bo.logic.common;
17  
18  import org.qedeq.base.utility.EqualsUtility;
19  
20  /**
21   * Predicate constant key, describing a predicate constant.
22   *
23   * @author  Michael Meyling
24   */
25  public final class PredicateKey {
26  
27      /** Predicate name. */
28      private String name;
29  
30      /** Predicate argument number. */
31      private String arguments;
32  
33      /**
34       * Constructor.
35       *
36       * @param   name        Predicate name.
37       * @param   arguments   Predicate argument number.
38       */
39      public PredicateKey(final String name, final String arguments) {
40          this.name = name;
41          this.arguments = arguments;
42      }
43  
44      /**
45       * Get predicate name.
46       *
47       * @return  Predicate name.
48       */
49      public String getName() {
50          return name;
51      }
52  
53      /**
54       * Get predicate argument number.
55       *
56       * @return  Number of arguments.
57       */
58      public String getArguments() {
59          return arguments;
60      }
61  
62      public int hashCode() {
63          return (getName() != null ? getName().hashCode() : 0)
64              ^ (getArguments() != null ? getArguments().hashCode() : 0);
65      }
66  
67      public boolean equals(final Object obj) {
68          if (!(obj instanceof PredicateKey)) {
69              return false;
70          }
71          final PredicateKey other = (PredicateKey) obj;
72          return EqualsUtility.equals(getName(), other.getName())
73              && EqualsUtility.equals(getArguments(), other.getArguments());
74      }
75  
76      public String toString() {
77          return getName() + "[" + getArguments() + "]";
78      }
79  
80  }