1 | /* This file is part of the project "Hilbert II" - 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.apache.commons.lang.ArrayUtils; |
19 | import org.qedeq.base.utility.EqualsUtility; |
20 | import org.qedeq.kernel.se.base.module.Add; |
21 | |
22 | |
23 | /** |
24 | * Usage of formula addition. |
25 | * |
26 | * @author Michael Meyling |
27 | */ |
28 | public class AddVo implements Add { |
29 | |
30 | /** Reference to previously proven formula. */ |
31 | private String reference; |
32 | |
33 | /** |
34 | * Constructs an addition argument. |
35 | * |
36 | * @param reference Reference to a valid formula. |
37 | */ |
38 | public AddVo(final String reference) { |
39 | this.reference = reference; |
40 | } |
41 | |
42 | /** |
43 | * Default constructor. |
44 | */ |
45 | public AddVo() { |
46 | // nothing to do |
47 | } |
48 | |
49 | public Add getAdd() { |
50 | return this; |
51 | } |
52 | |
53 | public String getReference() { |
54 | return reference; |
55 | } |
56 | |
57 | /** |
58 | * Set formula reference. |
59 | * |
60 | * @param reference Reference to formula. Might be <code>null</code>. |
61 | */ |
62 | public void setReference(final String reference) { |
63 | this.reference = reference; |
64 | } |
65 | |
66 | public String[] getReferences() { |
67 | if (reference == null) { |
68 | return ArrayUtils.EMPTY_STRING_ARRAY; |
69 | } |
70 | return new String[] {reference }; |
71 | } |
72 | |
73 | public boolean equals(final Object obj) { |
74 | if (!(obj instanceof AddVo)) { |
75 | return false; |
76 | } |
77 | final AddVo other = (AddVo) obj; |
78 | return EqualsUtility.equals(reference, other.reference); |
79 | } |
80 | |
81 | public int hashCode() { |
82 | return (reference != null ? reference.hashCode() : 0); |
83 | } |
84 | |
85 | public String toString() { |
86 | StringBuffer result = new StringBuffer(); |
87 | result.append("Add"); |
88 | if (reference != null) { |
89 | result.append(" ("); |
90 | result.append(reference); |
91 | result.append(")"); |
92 | } |
93 | return result.toString(); |
94 | } |
95 | |
96 | public String getName() { |
97 | return "Add"; |
98 | } |
99 | |
100 | } |