
ooaofooa.datatypes.End Maven / Gradle / Ivy
package ooaofooa.datatypes;
import io.ciera.runtime.summit.exceptions.XtumlException;
import io.ciera.runtime.summit.types.IXtumlType;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public enum End implements IXtumlType {
UNINITIALIZED_ENUM( -1 ),
END( 0 ),
END_FIXED( 1 ),
FLOATING( 2 ),
MIDDLE( 3 ),
NONE( 4 ),
START( 5 ),
START_FIXED( 6 );
private final int value;
End() {
value = -1;
}
End( int value ) {
this.value = value;
}
public int getValue() {
return value;
}
@Override
public boolean equality( IXtumlType value ) throws XtumlException {
if (value instanceof End) {
return null != value && this.value == ((End)value).getValue();
}
else return false;
}
@Override
public String serialize() {
return Integer.toString(value);
}
public static End deserialize(Object o) throws XtumlException {
if (o instanceof End) {
return (End)o;
}
else if (o instanceof Integer) {
return valueOf((int)o);
}
else if (o instanceof String) {
try {
return valueOf(Integer.parseInt((String)o));
}
catch (NumberFormatException e1) {
Matcher m = Pattern.compile("([A-Za-z][A-Za-z0-9_]*)::([A-Za-z][A-Za-z0-9_]*)").matcher((String)o);
if (m.matches() && "end".equals(m.group(1).toLowerCase())) {
try {
return Enum.valueOf(End.class, m.group(2).toUpperCase());
} catch (IllegalArgumentException e2) {/* do nothing */}
}
}
}
throw new XtumlException("Cannot deserialize value: " + o != null ? o.toString() : "null");
}
public static End valueOf(int value) {
switch( value ) {
case 0:
return END;
case 1:
return END_FIXED;
case 2:
return FLOATING;
case 3:
return MIDDLE;
case 4:
return NONE;
case 5:
return START;
case 6:
return START_FIXED;
default:
return UNINITIALIZED_ENUM;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy