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.list.Element;
20  import org.qedeq.kernel.se.base.module.Formula;
21  
22  
23  /**
24   * Wraps a formula. Such an object is build out of
25   * {@link org.qedeq.kernel.se.base.list.Element}s.
26   *
27   * @author  Michael Meyling
28   */
29  public class FormulaVo implements Formula {
30  
31      /** Formula. */
32      private Element element;
33  
34      /**
35       * Constructs a formula.
36       *
37       * @param   element    Element that should be a formula.
38       */
39      public FormulaVo(final Element element) {
40          this.element = element;
41      }
42  
43      /**
44       * Empty constructor.
45       */
46      public FormulaVo() {
47          // nothing to do
48      }
49  
50      /**
51       * Set formula.
52       *
53       * @param   element Formula.
54       */
55      public final void setElement(final Element element) {
56          this.element = element;
57      }
58  
59      public final Element getElement() {
60          return element;
61      }
62  
63      public boolean equals(final Object obj) {
64          if (!(obj instanceof FormulaVo)) {
65              return false;
66          }
67          final FormulaVo other = (FormulaVo) obj;
68          return EqualsUtility.equals(getElement(), other.getElement());
69      }
70  
71      public int hashCode() {
72          return (getElement() != null ? getElement().hashCode() : 0);
73      }
74  
75      public String toString() {
76          if (getElement() != null) {
77              return getElement().toString();
78          }
79          return "";
80      }
81  
82  }