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

org.ccsds.moims.mo.platform.structures.Vector3D Maven / Gradle / Ivy

package org.ccsds.moims.mo.platform.structures;

/**
 * The Vector3D holds a 3D Vector.
 */
public final class Vector3D implements org.ccsds.moims.mo.mal.structures.Composite
{
  /**
   * Short form for type.
   */
  public static final Integer TYPE_SHORT_FORM = Integer.valueOf(17);
  /**
   * Short form for area.
   */
  public static final org.ccsds.moims.mo.mal.structures.UShort AREA_SHORT_FORM = new org.ccsds.moims.mo.mal.structures.UShort(105);
  /**
   * Version for area.
   */
  public static final org.ccsds.moims.mo.mal.structures.UOctet AREA_VERSION = new org.ccsds.moims.mo.mal.structures.UOctet((short)1);
  /**
   * Short form for service.
   */
  public static final org.ccsds.moims.mo.mal.structures.UShort SERVICE_SHORT_FORM = new org.ccsds.moims.mo.mal.structures.UShort(0);
  /**
   * Absolute short form for type.
   */
  public static final Long SHORT_FORM = Long.valueOf(29554872571396113L);
  private static final long serialVersionUID = 29554872571396113L;
  /**
   * The x component of the Vector. The unit shall be defined by each specific case.
   */
  private Double x;
  /**
   * The y component of the Vector. The unit shall be defined by each specific case.
   */
  private Double y;
  /**
   * The z component of the Vector. The unit shall be defined by each specific case.
   */
  private Double z;
  /**
   * Default constructor for Vector3D.
   */
  public Vector3D()
  {
  }

  /**
   * Constructor that initialises the values of the structure.
   * @param x The x component of the Vector. The unit shall be defined by each specific case.
   * @param y The y component of the Vector. The unit shall be defined by each specific case.
   * @param z The z component of the Vector. The unit shall be defined by each specific case.
   */
  public Vector3D(Double x, Double y, Double z)
  {
    this.x = x;
    this.y = y;
    this.z = z;
  }

  /**
   * 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.platform.structures.Vector3D();
  }

  /**
   * Returns the field x.
   * @return The field x.
   */
  public Double getX()
  {
    return x;
  }

  /**
   * Sets the field x.
   * @param __newValue __newValue The new value.
   */
  public void setX(Double __newValue)
  {
    x = __newValue;
  }

  /**
   * Returns the field y.
   * @return The field y.
   */
  public Double getY()
  {
    return y;
  }

  /**
   * Sets the field y.
   * @param __newValue __newValue The new value.
   */
  public void setY(Double __newValue)
  {
    y = __newValue;
  }

  /**
   * Returns the field z.
   * @return The field z.
   */
  public Double getZ()
  {
    return z;
  }

  /**
   * Sets the field z.
   * @param __newValue __newValue The new value.
   */
  public void setZ(Double __newValue)
  {
    z = __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 obj the object to compare with.
   * @return true if the objects are the same; false otherwise.
   */
  public boolean equals(Object obj)
  {
    if (obj instanceof Vector3D)
    {
      Vector3D other = (Vector3D) obj;
      if (x == null)
      {
        if (other.x != null)
        {
          return false;
        }
      }
      else
      {
        if (! x.equals(other.x))
        {
          return false;
        }
      }
      if (y == null)
      {
        if (other.y != null)
        {
          return false;
        }
      }
      else
      {
        if (! y.equals(other.y))
        {
          return false;
        }
      }
      if (z == null)
      {
        if (other.z != null)
        {
          return false;
        }
      }
      else
      {
        if (! z.equals(other.z))
        {
          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 + (x != null ? x.hashCode() : 0);
    hash = 83 * hash + (y != null ? y.hashCode() : 0);
    hash = 83 * hash + (z != null ? z.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('(');
    buf.append("x=");
    buf.append(x);
    buf.append(", y=");
    buf.append(y);
    buf.append(", z=");
    buf.append(z);
    buf.append(')');
    return buf.toString();
  }

  /**
   * Encodes the value of this object using the provided MALEncoder.
   * @param encoder 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
  {
    encoder.encodeNullableDouble(x);
    encoder.encodeNullableDouble(y);
    encoder.encodeNullableDouble(z);
  }

  /**
   * Decodes the value of this object using the provided MALDecoder.
   * @param decoder 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
  {
    x = decoder.decodeNullableDouble();
    y = decoder.decodeNullableDouble();
    z = decoder.decodeNullableDouble();
    return this;
  }

  /**
   * Returns the absolute short form of this type.
   * @return The absolute short form of this type.
   */
  public Long getShortForm()
  {
    return SHORT_FORM;
  }

  /**
   * Returns the type short form of this type which is unique to the area/service it is defined in but not unique across all types.
   * @return The type short form of this type.
   */
  public Integer getTypeShortForm()
  {
    return TYPE_SHORT_FORM;
  }

  /**
   * Returns the area number of this type.
   * @return The area number of this type.
   */
  public org.ccsds.moims.mo.mal.structures.UShort getAreaNumber()
  {
    return AREA_SHORT_FORM;
  }

  /**
   * Returns the area version of this type.
   * @return The area number of this type.
   */
  public org.ccsds.moims.mo.mal.structures.UOctet getAreaVersion()
  {
    return AREA_VERSION;
  }

  /**
   * Returns the service number of this type.
   * @return The service number of this type.
   */
  public org.ccsds.moims.mo.mal.structures.UShort getServiceNumber()
  {
    return SERVICE_SHORT_FORM;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy