AddVo.java
01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02  *
03  * Copyright 2000-2011,  Michael Meyling <mime@qedeq.org>.
04  *
05  * "Hilbert II" is free software; you can redistribute
06  * it and/or modify it under the terms of the GNU General Public
07  * License as published by the Free Software Foundation; either
08  * version 2 of the License, or (at your option) any later version.
09  *
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.Add;
20 
21 
22 /**
23  * Usage of formula addition.
24  *
25  @author  Michael Meyling
26  */
27 public class AddVo implements Add {
28 
29     /** Reference to previously proven formula. */
30     private String reference;
31 
32     /**
33      * Constructs an addition argument.
34      *
35      @param   reference  Reference to a valid formula.
36      */
37     public AddVo(final String reference) {
38         this.reference = reference;
39     }
40 
41     /**
42      * Default constructor.
43      */
44     public AddVo() {
45         // nothing to do
46     }
47 
48     public String getReference() {
49         return reference;
50     }
51 
52     /**
53      * Set formula reference.
54      *
55      @param   reference   Reference to formula.
56      */
57     public void setReference(final String reference) {
58         this.reference = reference;
59     }
60 
61     public String[] getReferences() {
62         if (reference == null || reference.length() == 0) {
63             return new String[] {};
64         else {
65             return new String[] {reference };
66         }
67     }
68 
69     public boolean equals(final Object obj) {
70         if (!(obj instanceof AddVo)) {
71             return false;
72         }
73         final AddVo other = (AddVoobj;
74         return  EqualsUtility.equals(reference, other.reference);
75     }
76 
77     public int hashCode() {
78         return (reference != null ? reference.hashCode() 0);
79     }
80 
81     public String toString() {
82         StringBuffer result = new StringBuffer();
83         result.append("Add");
84         if (reference != null) {
85             result.append(" (");
86             if (reference != null) {
87                 result.append(reference);
88             }
89             result.append(")");
90         }
91         return result.toString();
92     }
93 
94     public String getName() {
95         return "Add";
96     }
97 
98 }