001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002 *
003 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
004 *
005 * "Hilbert II" is free software; you can redistribute
006 * it and/or modify it under the terms of the GNU General Public
007 * License as published by the Free Software Foundation; either
008 * version 2 of the License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU General Public License for more details.
014 */
015
016 package org.qedeq.kernel.se.dto.module;
017
018 import org.apache.commons.lang.ArrayUtils;
019 import org.qedeq.base.utility.EqualsUtility;
020 import org.qedeq.kernel.se.base.module.Add;
021
022
023 /**
024 * Usage of formula addition.
025 *
026 * @author Michael Meyling
027 */
028 public class AddVo implements Add {
029
030 /** Reference to previously proven formula. */
031 private String reference;
032
033 /**
034 * Constructs an addition argument.
035 *
036 * @param reference Reference to a valid formula.
037 */
038 public AddVo(final String reference) {
039 this.reference = reference;
040 }
041
042 /**
043 * Default constructor.
044 */
045 public AddVo() {
046 // nothing to do
047 }
048
049 public Add getAdd() {
050 return this;
051 }
052
053 public String getReference() {
054 return reference;
055 }
056
057 /**
058 * Set formula reference.
059 *
060 * @param reference Reference to formula. Might be <code>null</code>.
061 */
062 public void setReference(final String reference) {
063 this.reference = reference;
064 }
065
066 public String[] getReferences() {
067 if (reference == null) {
068 return ArrayUtils.EMPTY_STRING_ARRAY;
069 }
070 return new String[] {reference };
071 }
072
073 public boolean equals(final Object obj) {
074 if (!(obj instanceof AddVo)) {
075 return false;
076 }
077 final AddVo other = (AddVo) obj;
078 return EqualsUtility.equals(reference, other.reference);
079 }
080
081 public int hashCode() {
082 return (reference != null ? reference.hashCode() : 0);
083 }
084
085 public String toString() {
086 StringBuffer result = new StringBuffer();
087 result.append("Add");
088 if (reference != null) {
089 result.append(" (");
090 result.append(reference);
091 result.append(")");
092 }
093 return result.toString();
094 }
095
096 public String getName() {
097 return "Add";
098 }
099
100 }
|