org.ccsds.moims.mo.common.login.structures.Profile Maven / Gradle / Ivy
package org.ccsds.moims.mo.common.login.structures;
/**
* The Profile structure contains details of the user who is logging on to
* take a specified role.
*/
public final class Profile implements org.ccsds.moims.mo.mal.structures.Composite {
/**
* Short form for type.
*/
@Deprecated
private static final Integer TYPE_SHORT_FORM = 1;
/**
* Absolute short form for type. This will be replaced by the TypeId.
*/
@Deprecated
public static final Long SHORT_FORM = 844433536843777L;
private static final long serialVersionUID = 844433536843777L;
/**
* Absolute short form for type.
*/
public static final org.ccsds.moims.mo.mal.TypeId TYPE_ID = new org.ccsds.moims.mo.mal.TypeId(SHORT_FORM);
/**
* The name of the user.
*/
private org.ccsds.moims.mo.mal.structures.Identifier username;
/**
* The optional object instance identifier of the role required by the user.
*/
private Long role;
/**
* Default constructor for Profile.
*
*/
public Profile() {
}
/**
* Constructor that initialises the values of the structure.
*
* @param username The name of the user.
* @param role The optional object instance identifier of the role required
* by the user.
*/
public Profile(org.ccsds.moims.mo.mal.structures.Identifier username,
Long role) {
this.username = username;
this.role = role;
}
/**
* Constructor that initialises the non-nullable values of the structure.
*
* @param username The name of the user.
*/
public Profile(org.ccsds.moims.mo.mal.structures.Identifier username) {
this.username = username;
this.role = 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.common.login.structures.Profile();
}
/**
* Returns the field username.
*
* @return The field username.
*/
public org.ccsds.moims.mo.mal.structures.Identifier getUsername() {
return username;
}
/**
* Sets the field username.
*
* @param __newValue The new value.
*/
@Deprecated
public void setUsername(org.ccsds.moims.mo.mal.structures.Identifier __newValue) {
username = __newValue;
}
/**
* Returns the field role.
*
* @return The field role.
*/
public Long getRole() {
return role;
}
/**
* Sets the field role.
*
* @param __newValue The new value.
*/
@Deprecated
public void setRole(Long __newValue) {
role = __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 Profile) {
Profile other = (Profile) obj;
if (username == null) {
if (other.username != null) {
return false;
}
} else {
if (! username.equals(other.username)) {
return false;
}
}
if (role == null) {
if (other.role != null) {
return false;
}
} else {
if (! role.equals(other.role)) {
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 + (username != null ? username.hashCode() : 0);
hash = 83 * hash + (role != null ? role.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("(Profile: ");
buf.append("username=");
buf.append(username);
buf.append(", role=");
buf.append(role);
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 (username == null) {
throw new org.ccsds.moims.mo.mal.MALException("The field 'username' cannot be null!");
}
encoder.encodeIdentifier(username);
encoder.encodeNullableLong(role);
}
/**
* 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 {
username = decoder.decodeIdentifier();
role = decoder.decodeNullableLong();
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.common.CommonHelper.COMMON_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.common.CommonHelper.COMMON_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 org.ccsds.moims.mo.common.login.LoginServiceInfo.LOGIN_SERVICE_NUMBER;
}
/**
* Returns the TypeId of this element.
*
* @return The TypeId of this element.
*/
public org.ccsds.moims.mo.mal.TypeId getTypeId() {
return TYPE_ID;
}
}