org.ccsds.moims.mo.mpd.structures.ValueRange Maven / Gradle / Ivy
The newest version!
package org.ccsds.moims.mo.mpd.structures;
/**
* A ValueRange is a concrete subtype of ParameterFilter that allows the specification
* of an allowed (or disallowed) value range for a metadata parameter.
*/
public final class ValueRange extends org.ccsds.moims.mo.mpd.structures.ParameterFilter {
private static final long serialVersionUID = 2533274807173123L;
/**
* The TypeId of this Element as a long.
*/
public static final Long SHORT_FORM = 2533274807173123L;
/**
* 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);
/**
* Minimum value of the value range (greater than or equal to).
*/
private org.ccsds.moims.mo.mal.structures.Attribute minimum;
/**
* Maximum value of the value range (less than or equal to).
*/
private org.ccsds.moims.mo.mal.structures.Attribute maximum;
/**
* Default constructor for ValueRange.
*
*/
public ValueRange() {
}
/**
* Constructor that initialises the values of the structure.
*
* @param name References the name of a defined metadata parameter.
* @param include Indicates whether the filter is to include [TRUE] or exclude
* [FALSE] parameter values that match the filter.
* @param minimum Minimum value of the value range (greater than or equal
* to).
* @param maximum Maximum value of the value range (less than or equal to).
*/
public ValueRange(org.ccsds.moims.mo.mal.structures.Identifier name,
Boolean include,
org.ccsds.moims.mo.mal.structures.Attribute minimum,
org.ccsds.moims.mo.mal.structures.Attribute maximum) {
super(name,
include);
this.minimum = minimum;
this.maximum = maximum;
}
/**
* Constructor that initialises the non-nullable values of the structure.
*
* @param name References the name of a defined metadata parameter.
* @param include Indicates whether the filter is to include [TRUE] or exclude
* [FALSE] parameter values that match the filter.
*/
public ValueRange(org.ccsds.moims.mo.mal.structures.Identifier name,
Boolean include) {
super(name,
include);
this.minimum = null;
this.maximum = null;
}
/**
* 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.ValueRange();
}
/**
* Returns the field minimum.
*
* @return The field minimum.
*/
public org.ccsds.moims.mo.mal.structures.Attribute getMinimum() {
return minimum;
}
/**
* Sets the field minimum.
*
* @param __newValue The new value.
*/
@Deprecated
public void setMinimum(org.ccsds.moims.mo.mal.structures.Attribute __newValue) {
minimum = __newValue;
}
/**
* Returns the field maximum.
*
* @return The field maximum.
*/
public org.ccsds.moims.mo.mal.structures.Attribute getMaximum() {
return maximum;
}
/**
* Sets the field maximum.
*
* @param __newValue The new value.
*/
@Deprecated
public void setMaximum(org.ccsds.moims.mo.mal.structures.Attribute __newValue) {
maximum = __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 ValueRange) {
if (! super.equals(obj)) {
return false;
}
ValueRange other = (ValueRange) obj;
if (minimum == null) {
if (other.minimum != null) {
return false;
}
} else {
if (! minimum.equals(other.minimum)) {
return false;
}
}
if (maximum == null) {
if (other.maximum != null) {
return false;
}
} else {
if (! maximum.equals(other.maximum)) {
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 = super.hashCode();
hash = 83 * hash + (minimum != null ? minimum.hashCode() : 0);
hash = 83 * hash + (maximum != null ? maximum.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("(ValueRange: ");
buf.append(super.toString());
buf.append(", minimum=");
buf.append(minimum);
buf.append(", maximum=");
buf.append(maximum);
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 {
super.encode(encoder);
encoder.encodeNullableAttribute(minimum);
encoder.encodeNullableAttribute(maximum);
}
/**
* 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 {
super.decode(decoder);
minimum = (org.ccsds.moims.mo.mal.structures.Attribute) decoder.decodeNullableAttribute();
maximum = (org.ccsds.moims.mo.mal.structures.Attribute) decoder.decodeNullableAttribute();
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;
}
}