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

org.ccsds.moims.mo.mpd.structures.TimeWindow Maven / Gradle / Ivy

The newest version!
package org.ccsds.moims.mo.mpd.structures;

/**
 * Represents a specific period of time, specified as two fields of type Time 
 * defining the start and end of the TimeWindow. 
 */
public final class TimeWindow implements org.ccsds.moims.mo.mal.structures.Composite {

    private static final long serialVersionUID = 2533274807173121L;
    /**
     * The TypeId of this Element as a long.
     */
    public static final Long SHORT_FORM = 2533274807173121L;
    /**
     * The TypeId of this Element.
     */
    public static final org.ccsds.moims.mo.mal.TypeId TYPE_ID = new org.ccsds.moims.mo.mal.TypeId(SHORT_FORM);

    /**
     * Start time of the time window.
     */
    private org.ccsds.moims.mo.mal.structures.Time start;

    /**
     * End time of the time window.
     */
    private org.ccsds.moims.mo.mal.structures.Time end;

    /**
     * Default constructor for TimeWindow.
     * 
     */
    public TimeWindow() {
    }

    /**
     * Constructor that initialises the values of the structure.
     * 
     * @param start Start time of the time window.
     * @param end End time of the time window.
     */
    public TimeWindow(org.ccsds.moims.mo.mal.structures.Time start,
            org.ccsds.moims.mo.mal.structures.Time end) {
        this.start = start;
        this.end = end;
    }

    /**
     * Creates an instance of this type using the default constructor. It is a 
     * generic factory method. 
     * 
     * @return A new instance of this type with default field values.
     */
    public org.ccsds.moims.mo.mal.structures.Element createElement() {
        return new org.ccsds.moims.mo.mpd.structures.TimeWindow();
    }

    /**
     * Returns the field start.
     * 
     * @return The field start.
     */
    public org.ccsds.moims.mo.mal.structures.Time getStart() {
        return start;
    }

    /**
     * Sets the field start.
     * 
     * @param __newValue The new value.
     */
    @Deprecated
    public void setStart(org.ccsds.moims.mo.mal.structures.Time __newValue) {
        start = __newValue;
    }

    /**
     * Returns the field end.
     * 
     * @return The field end.
     */
    public org.ccsds.moims.mo.mal.structures.Time getEnd() {
        return end;
    }

    /**
     * Sets the field end.
     * 
     * @param __newValue The new value.
     */
    @Deprecated
    public void setEnd(org.ccsds.moims.mo.mal.structures.Time __newValue) {
        end = __newValue;
    }

    /**
     * Compares this object to the specified object. The result is true if and 
     * only if the argument is not null and is the same type that contains the 
     * same value as this object. 
     * 
     * @param obj The object to compare with.
     * @return true if the objects are the same; false otherwise.
     */
    public boolean equals(Object obj) {
        if (obj instanceof TimeWindow) {
            TimeWindow other = (TimeWindow) obj;
            if (start == null) {
                if (other.start != null) {
                    return false;
                }
            } else {
                if (! start.equals(other.start)) {
                    return false;
                }
            }
            if (end == null) {
                if (other.end != null) {
                    return false;
                }
            } else {
                if (! end.equals(other.end)) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }

    /**
     * Returns a hash code for this object.
     * 
     * @return a hash code value for this object.
     */
    public int hashCode() {
        int hash = 7;
        hash = 83 * hash + (start != null ? start.hashCode() : 0);
        hash = 83 * hash + (end != null ? end.hashCode() : 0);
        return hash;
    }

    /**
     * Returns a String object representing this type"s value.
     * 
     * @return a string representation of the value of this object.
     */
    public String toString() {
        StringBuilder buf = new StringBuilder();
        buf.append("(TimeWindow: ");
        buf.append("start=");
        buf.append(start);
        buf.append(", end=");
        buf.append(end);
        buf.append(')');
        return buf.toString();
    }

    /**
     * Encodes the value of this object using the provided MALEncoder.
     * 
     * @param encoder The encoder to use for encoding.
     * @throws org.ccsds.moims.mo.mal.MALException if any encoding errors are 
     * detected. 
     */
    public void encode(org.ccsds.moims.mo.mal.MALEncoder encoder) throws org.ccsds.moims.mo.mal.MALException {
        if (start == null) {
            throw new org.ccsds.moims.mo.mal.MALException("The field 'start' cannot be null!");
        }
        if (end == null) {
            throw new org.ccsds.moims.mo.mal.MALException("The field 'end' cannot be null!");
        }
        encoder.encodeTime(start);
        encoder.encodeTime(end);
    }

    /**
     * Decodes the value of this object using the provided MALDecoder.
     * 
     * @param decoder The decoder to use for decoding.
     * @return Returns this object.
     * @throws org.ccsds.moims.mo.mal.MALException if any decoding errors are 
     * detected. 
     */
    public org.ccsds.moims.mo.mal.structures.Element decode(org.ccsds.moims.mo.mal.MALDecoder decoder) throws org.ccsds.moims.mo.mal.MALException {
        start = decoder.decodeTime();
        end = decoder.decodeTime();
        return this;
    }

    /**
     * Returns the TypeId of this element.
     * 
     * @return The TypeId of this element.
     */
    public org.ccsds.moims.mo.mal.TypeId getTypeId() {
        return TYPE_ID;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy