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 } else {
070 return new String[] {reference };
071 }
072 }
073
074 public boolean equals(final Object obj) {
075 if (!(obj instanceof AddVo)) {
076 return false;
077 }
078 final AddVo other = (AddVo) obj;
079 return EqualsUtility.equals(reference, other.reference);
080 }
081
082 public int hashCode() {
083 return (reference != null ? reference.hashCode() : 0);
084 }
085
086 public String toString() {
087 StringBuffer result = new StringBuffer();
088 result.append("Add");
089 if (reference != null) {
090 result.append(" (");
091 result.append(reference);
092 result.append(")");
093 }
094 return result.toString();
095 }
096
097 public String getName() {
098 return "Add";
099 }
100
101 }
|