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

org.ccsds.moims.mo.mal.structures.Enumeration Maven / Gradle / Ivy

There is a newer version: 10.1
Show newest version
/* ----------------------------------------------------------------------------
 * Copyright (C) 2013      European Space Agency
 *                         European Space Operations Centre
 *                         Darmstadt
 *                         Germany
 * ----------------------------------------------------------------------------
 * System                : CCSDS MO MAL Java API
 * ----------------------------------------------------------------------------
 * Licensed under the European Space Agency Public License, Version 2.0
 * You may not use this file except in compliance with the License.
 *
 * Except as expressly set forth in this License, the Software is provided to
 * You on an "as is" basis and without warranties of any kind, including without
 * limitation merchantability, fitness for a particular purpose, absence of
 * defects or errors, accuracy or non-infringement of intellectual property rights.
 * 
 * See the License for the specific language governing permissions and
 * limitations under the License. 
 * ----------------------------------------------------------------------------
 */
package org.ccsds.moims.mo.mal.structures;

/**
 * The abstract class represents the MAL Enumeration type. The class is extended
 * by the classes representing MAL enumeration types.
 *
 */
public abstract class Enumeration implements Element {

    /**
     * The index of the enumerated item, i.e. its position in the enumeration
     * declaration starting from zero.
     */
    protected Integer ordinal;

    /**
     * Returns the index of the enumerated item.
     *
     * @return the index of the enumerated item.
     */
    public final int getOrdinal() {
        return ordinal;
    }

    /**
     * Returns the numeric value of the enumerated item.
     *
     * @return the numeric value of the enumerated item.
     */
    public abstract UInteger getNumericValue();

    @Override
    public int hashCode() {
        return ordinal;
    }

    @Override
    public boolean equals(final Object o) {
        if (o == null) {
            return false;
        }

        if (o == this) {
            return true;
        }

        if (o instanceof Enumeration) {
            return 0 == ordinal.compareTo(((Enumeration) o).ordinal);
        }
        return false;
    }

    /**
     * The ordinal constructor, takes as a parameter the index of the enumerated
     * item, i.e. its position in the enumeration declaration starting from
     * zero.
     *
     * @param ordinal The index of the enumerated item.
     */
    protected Enumeration(final int ordinal) {
        this.ordinal = ordinal;
    }
    
//  This might be required for XML serialisation and technologies that use that.  
//  public final void setOrdinal(int ordinal)
//  {
//    this.ordinal = ordinal;
//  }
//  This might be required for XML serialisation and technologies that use that.  
//  protected Enumeration()
//  {
//    this.ordinal = 0;
//  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy