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.dto.module;
17  
18  import org.qedeq.base.utility.EqualsUtility;
19  import org.qedeq.kernel.se.base.module.Formula;
20  import org.qedeq.kernel.se.base.module.Hypothesis;
21  
22  
23  /**
24   * Hypothesis that can be used as an assumption within a proof.
25   *
26   * @author  Michael Meyling
27   */
28  public class HypothesisVo implements Hypothesis {
29  
30      /** Label for back references. Might be <code>null</code>. */
31      private String label;
32  
33      /** Derived formula. */
34      private Formula formula;
35  
36      /**
37       * Constructs an proof line.
38       *
39       * @param   formula     New derived formula.
40       */
41      public HypothesisVo(final Formula formula) {
42          this.label = null;
43          this.formula = formula;
44      }
45  
46      /**
47       * Constructs an proof line.
48       *
49       * @param   label       Label for back references. Might be <code>null</code>.
50       * @param   formula     New derived formula.
51       */
52      public HypothesisVo(final String label, final Formula formula) {
53          this.label = label;
54          this.formula = formula;
55      }
56  
57      /**
58       * Default constructor.
59       */
60      public HypothesisVo() {
61          // nothing to do
62      }
63  
64      public Formula getFormula() {
65          return formula;
66      }
67  
68      /**
69       * Set proof line formula.
70       *
71       * @param   formula Set formula.
72       */
73      public void setFormula(final Formula formula) {
74          this.formula = formula;
75      }
76  
77      public String getLabel() {
78          return label;
79      }
80  
81      /**
82       * Set label for proof line.
83       *
84       * @param   label   Set this label.
85       */
86      public void setLabel(final String label) {
87          this.label = label;
88      }
89  
90      public boolean equals(final Object obj) {
91          if (!(obj instanceof HypothesisVo)) {
92              return false;
93          }
94          final HypothesisVo other = (HypothesisVo) obj;
95          return  EqualsUtility.equals(label, other.label)
96            && EqualsUtility.equals(formula, other.formula);
97      }
98  
99      public int hashCode() {
100         return (label != null ? label.hashCode() : 0)
101            ^ (formula != null ?  1 ^ formula.hashCode() : 0);
102     }
103 
104     public String toString() {
105         return (label != null ? "[" + label + "] " : "    ") + getFormula() + " "
106             + "Hypothesis";
107     }
108 
109 }