AddVo.java
001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002  *
003  * Copyright 2000-2011,  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.qedeq.base.utility.EqualsUtility;
019 import org.qedeq.kernel.se.base.module.Add;
020 
021 
022 /**
023  * Usage of formula addition.
024  *
025  @author  Michael Meyling
026  */
027 public class AddVo implements Add {
028 
029     /** Reference to previously proven formula. */
030     private String reference;
031 
032     /**
033      * Constructs an addition argument.
034      *
035      @param   reference  Reference to a valid formula.
036      */
037     public AddVo(final String reference) {
038         this.reference = reference;
039     }
040 
041     /**
042      * Default constructor.
043      */
044     public AddVo() {
045         // nothing to do
046     }
047 
048     public Add getAdd() {
049         return this;
050     }
051 
052     public String getReference() {
053         return reference;
054     }
055 
056     /**
057      * Set formula reference.
058      *
059      @param   reference   Reference to formula.
060      */
061     public void setReference(final String reference) {
062         this.reference = reference;
063     }
064 
065     public String[] getReferences() {
066         if (reference == null || reference.length() == 0) {
067             return new String[] {};
068         else {
069             return new String[] {reference };
070         }
071     }
072 
073     public boolean equals(final Object obj) {
074         if (!(obj instanceof AddVo)) {
075             return false;
076         }
077         final AddVo other = (AddVoobj;
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             if (reference != null) {
091                 result.append(reference);
092             }
093             result.append(")");
094         }
095         return result.toString();
096     }
097 
098     public String getName() {
099         return "Add";
100     }
101 
102 }