org.ccsds.moims.mo.mal.structures.Pair Maven / Gradle / Ivy
package org.ccsds.moims.mo.mal.structures;
/**
* Pair shall be a simple Composite structure for holding pairs.
*/
public final class Pair implements org.ccsds.moims.mo.mal.structures.Composite {
/**
* Short form for type.
*/
public static final Integer TYPE_SHORT_FORM = 1005;
/**
* Absolute short form for type.
*/
public static final Long SHORT_FORM = 281475027043309L;
private static final long serialVersionUID = 281475027043309L;
/**
* The attribute value for the first Element of this pair.
*/
private org.ccsds.moims.mo.mal.structures.Attribute first;
/**
* The attribute value for the second Element of this pair.
*/
private org.ccsds.moims.mo.mal.structures.Attribute second;
/**
* Default constructor for Pair.
*
*/
public Pair() {
}
/**
* Constructor that initialises the values of the structure.
*
* @param first The attribute value for the first Element of this pair.
* @param second The attribute value for the second Element of this pair.
*/
public Pair(org.ccsds.moims.mo.mal.structures.Attribute first,
org.ccsds.moims.mo.mal.structures.Attribute second) {
this.first = first;
this.second = second;
}
/**
* 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.mal.structures.Pair();
}
/**
* Returns the field first.
*
* @return The field first.
*/
public org.ccsds.moims.mo.mal.structures.Attribute getFirst() {
return first;
}
/**
* Sets the field first.
*
* @param __newValue The new value.
*/
@Deprecated
public void setFirst(org.ccsds.moims.mo.mal.structures.Attribute __newValue) {
first = __newValue;
}
/**
* Returns the field second.
*
* @return The field second.
*/
public org.ccsds.moims.mo.mal.structures.Attribute getSecond() {
return second;
}
/**
* Sets the field second.
*
* @param __newValue The new value.
*/
@Deprecated
public void setSecond(org.ccsds.moims.mo.mal.structures.Attribute __newValue) {
second = __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 Pair) {
Pair other = (Pair) obj;
if (first == null) {
if (other.first != null) {
return false;
}
} else {
if (! first.equals(other.first)) {
return false;
}
}
if (second == null) {
if (other.second != null) {
return false;
}
} else {
if (! second.equals(other.second)) {
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 + (first != null ? first.hashCode() : 0);
hash = 83 * hash + (second != null ? second.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("(Pair: ");
buf.append("first=");
buf.append(first);
buf.append(", second=");
buf.append(second);
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 {
encoder.encodeNullableAttribute(first);
encoder.encodeNullableAttribute(second);
}
/**
* 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 {
first = (org.ccsds.moims.mo.mal.structures.Attribute) decoder.decodeNullableAttribute();
second = (org.ccsds.moims.mo.mal.structures.Attribute) decoder.decodeNullableAttribute();
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 org.ccsds.moims.mo.mal.MALHelper.MAL_AREA_NUMBER;
}
/**
* Returns the area version of this type.
*
* @return The area number of this type.
*/
public org.ccsds.moims.mo.mal.structures.UOctet getAreaVersion() {
return org.ccsds.moims.mo.mal.MALHelper.MAL_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 new org.ccsds.moims.mo.mal.structures.UShort(0);
}
}