All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ooaofooa.datatypes.ActionDialect Maven / Gradle / Ivy

There is a newer version: 2.7.3
Show newest version
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 ActionDialect implements IXtumlType {

    UNINITIALIZED_ENUM( -1 ),
    ALF( 3 ),
    ASL( 2 ),
    C( 5 ),
    JAVA( 4 ),
    MASL( 1 ),
    NONE( 6 ),
    OAL( 0 );

    private final int value;

    ActionDialect() {
        value = -1;
    }

    ActionDialect( int value ) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }

    @Override
    public boolean equality( IXtumlType value ) throws XtumlException {
        if (value instanceof ActionDialect) {
            return null != value && this.value == ((ActionDialect)value).getValue();
        }
        else return false;
    }

    @Override
    public String serialize() {
        return Integer.toString(value);
    }

    public static ActionDialect deserialize(Object o) throws XtumlException {
        if (o instanceof ActionDialect) {
            return (ActionDialect)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() && "actiondialect".equals(m.group(1).toLowerCase())) {
                    try {
                        return Enum.valueOf(ActionDialect.class, m.group(2).toUpperCase());
                    } catch (IllegalArgumentException e2) {/* do nothing */}
                }
            }
        }
        throw new XtumlException("Cannot deserialize value: " + o != null ? o.toString() : "null");
    }

    public static ActionDialect valueOf(int value) {
        switch( value ) {
        case 3:
            return ALF;
        case 2:
            return ASL;
        case 5:
            return C;
        case 4:
            return JAVA;
        case 1:
            return MASL;
        case 6:
            return NONE;
        case 0:
            return OAL;
        default:
            return UNINITIALIZED_ENUM;
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy