72 lines
1.4 KiB
Java
72 lines
1.4 KiB
Java
/*
|
|
* Copyright (c) DuxTechnica
|
|
*
|
|
* Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not
|
|
* use this file except in compliance with the License. You may obtain a copy of the License by
|
|
* contacting:
|
|
*
|
|
* Dux Technica, [email protected]
|
|
*
|
|
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
* either express or implied. See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package dxt.moe.model;
|
|
|
|
/**
|
|
* A simple data type that can hold a string, number, or boolean value.
|
|
*
|
|
* @author indroneel
|
|
*/
|
|
|
|
public class SimpleData {
|
|
|
|
private final String strVal;
|
|
private final Number numVal;
|
|
private final Boolean boolVal;
|
|
|
|
public SimpleData(String value) {
|
|
strVal = value;
|
|
numVal = null;
|
|
boolVal = null;
|
|
}
|
|
|
|
public SimpleData(Number value) {
|
|
strVal = null;
|
|
numVal = value;
|
|
boolVal = null;
|
|
}
|
|
|
|
public SimpleData(Boolean value) {
|
|
strVal = null;
|
|
numVal = null;
|
|
boolVal = value;
|
|
}
|
|
|
|
public String getString() {
|
|
return strVal;
|
|
}
|
|
|
|
public Boolean getBoolean() {
|
|
return boolVal;
|
|
}
|
|
|
|
public Number getNumber() {
|
|
return numVal;
|
|
}
|
|
|
|
public String toString() {
|
|
if(strVal != null) {
|
|
return "string: " + strVal;
|
|
}
|
|
if(numVal != null) {
|
|
return "number: " + numVal.toString();
|
|
}
|
|
if(boolVal != null) {
|
|
return "boolean: " + boolVal.toString();
|
|
}
|
|
return "impossible!";
|
|
}
|
|
}
|