Commit 3855323c authored by Nico Mack's avatar Nico Mack

Deleted obsolete and unused GenericVariable class

parent dd209aab
/**
* Copyright Luxembourg Institute of Science and Technology, 2016.
*
* This file is part of TULIP.
*
* TULIP is licensed under a dual-licensing scheme. For non-commercial purposes, the LGPL version 3,
* as stated below, is applicable. For all commercial purposes TULIP is licensed under a LIST
* proprietary license. Please contact LIST at tto@list.lu to obtain a commercial license.
*
* For all non-commercial purposes, TULIP is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, version 3 of the License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.cps.variable;
import lu.list.itis.dkd.dbc.annotation.NonNullByDefault;
import lu.list.itis.dkd.dbc.annotation.Nullable;
import lu.list.itis.dkd.tui.cps.utility.EquationSystemBundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Vector;
/**
* Class implementing a generic variables as handled by the {@link System}.
*
* @author Nico Mack [nico.mack@list.lu]
* @since 1.7.0
* @version 1.0.0
*/
@NonNullByDefault
public class GenericVariable extends Variable<Object> {
private Object initialValue;
private static final Logger LOGGER = LoggerFactory.getLogger(GenericVariable.class.getSimpleName());
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
public GenericVariable(String name) {
super(EquationSystemBundle.TEXT_TYPE, name);
this.value = EquationSystemBundle.EMPTY_STRING;
}
// ---------------------------------------------------------------------------
/**
* Constructor resorting to the super constructor to initialise the name and unit and locally
* initialising the numerical value.
*
* @param name
* The name of the variable.
* @param unit
* The unit the variable is given in.
* @param value
* The value held by the variable.
*/
// ---------------------------------------------------------------------------
public GenericVariable(String name, Object value) {
super(EquationSystemBundle.TEXT_TYPE, name, EquationSystemBundle.EMPTY_STRING);
initialValue = value;
this.clear();
}
/**
* {@inheritDoc}<br>
* <br>
*
* The method constructs a string separating the value and the unit with a space.
*/
@Override
public String toString() {
return (this.value != null) ? this.value.toString() : "null";
}
/**
* {@inheritDoc}<br>
* <br>
*
* The hash code is based on the <code>toString()</code> representation of this class.
*/
@Override
public int hashCode() {
return toString().hashCode();
}
/**
* {@inheritDoc}<br>
* <br>
*
* The equality test is base on equality of name, unit, and value.
*/
@Override
public boolean equals(@Nullable Object object) {
if (object == null)
return false;
if (object == this)
return true;
if (object instanceof GenericVariable) {
GenericVariable variable = (GenericVariable) object;
if (name.equals(variable.getName()) && unit.equals(variable.getUnit()) && variable.getValue().equals(value)) {
return true;
}
}
return false;
}
/** {@inheritDoc} */
@Override
public void setValueFromObject(Object object) {
this.setValue(this.valueFromObject(object));
}
@Override
public void clear() {
this.setValue(this.initialValue);
}
/** {@inheritDoc} */
@Override
public GenericVariable clone() {
GenericVariable variable = new GenericVariable(name, value);
variable.listeners = new Vector<>(listeners);
return variable;
}
/** {@inheritDoc} */
@Override
public Object valueFromString(String stringValue) {
return stringValue;
}
@Override
public Object valueFromObject(Object objectValue) {
return objectValue;
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment