
com.arm.mbed.cloud.sdk.accounts.model.ActiveSession Maven / Gradle / Ivy
// This file was generated by the Pelion SDK foundation code generator.
// This is an autogenerated class. Do not modify its content as modifications will be lost at next code generation.
package com.arm.mbed.cloud.sdk.accounts.model;
import com.arm.mbed.cloud.sdk.annotations.Internal;
import com.arm.mbed.cloud.sdk.annotations.PerformsNoOperation;
import com.arm.mbed.cloud.sdk.annotations.Preamble;
import com.arm.mbed.cloud.sdk.common.SdkModel;
import java.util.Date;
/**
* Model for an active session.
*/
@Preamble(description = "Model for an active session.")
public class ActiveSession implements SdkModel {
/**
* Serialisation Id.
*/
private static final long serialVersionUID = 1812217672132092L;
/**
* The UUID of the account.
*/
private final String accountId;
/**
* IP address of the client.
*/
private final String ipAddress;
/**
* The login time of the user.
*/
private final Date loginTime;
/**
* The reference token.
*/
private final String referenceToken;
/**
* User Agent header from the login request.
*/
private final String userAgent;
/**
* Internal constructor.
*
*
* Constructor based on all fields.
*
* Note: Should not be used. Use {@link #ActiveSession()} instead.
*
* @param accountId
* The UUID of the account.
* @param ipAddress
* IP address of the client.
* @param loginTime
* The login time of the user.
* @param referenceToken
* The reference token.
* @param userAgent
* User Agent header from the login request.
*/
@Internal
public ActiveSession(String accountId, String ipAddress, Date loginTime, String referenceToken, String userAgent) {
super();
this.accountId = accountId;
this.ipAddress = ipAddress;
this.loginTime = loginTime;
this.referenceToken = referenceToken;
this.userAgent = userAgent;
}
/**
* Internal constructor.
*
*
* Constructor based on a similar object.
*
* Note: Should not be used. Use {@link #ActiveSession()} instead.
*
* @param activeSession
* an active session.
*/
@Internal
public ActiveSession(ActiveSession activeSession) {
this(activeSession == null ? (String) null : activeSession.accountId,
activeSession == null ? (String) null : activeSession.ipAddress,
activeSession == null ? new Date() : activeSession.loginTime,
activeSession == null ? (String) null : activeSession.referenceToken,
activeSession == null ? (String) null : activeSession.userAgent);
}
/**
* Constructor.
*/
public ActiveSession() {
this((String) null, (String) null, new Date(), (String) null, (String) null);
}
/**
* Sets id.
*
* @param id
* id.
*/
@Override
@Internal
@PerformsNoOperation
public void setId(String id) {
// Nothing to do
}
/**
* Gets id.
*
*
* Warning: ActiveSession model does not have any ID field. This always returns {@code null}.
*
* @return id
*/
@Override
@Internal
public String getId() {
return null;
}
/**
* Gets the uuid of the account.
*
* @return accountId
*/
public String getAccountId() {
return accountId;
}
/**
* Gets ip address of the client.
*
* @return ipAddress
*/
public String getIpAddress() {
return ipAddress;
}
/**
* Gets the login time of the user.
*
* @return loginTime
*/
public Date getLoginTime() {
return loginTime;
}
/**
* Gets the reference token.
*
* @return referenceToken
*/
public String getReferenceToken() {
return referenceToken;
}
/**
* Gets user agent header from the login request.
*
* @return userAgent
*/
public String getUserAgent() {
return userAgent;
}
/**
* Returns a string representation of the object.
*
*
*
* @see java.lang.Object#toString()
* @return the string representation
*/
@Override
public String toString() {
return "ActiveSession [accountId=" + accountId + ", ipAddress=" + ipAddress + ", loginTime=" + loginTime
+ ", referenceToken=" + referenceToken + ", userAgent=" + userAgent + "]";
}
/**
* Calculates the hash code of this instance based on field values.
*
*
*
* @see java.lang.Object#hashCode()
* @return hash code
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((accountId == null) ? 0 : accountId.hashCode());
result = prime * result + ((ipAddress == null) ? 0 : ipAddress.hashCode());
result = prime * result + ((loginTime == null) ? 0 : loginTime.hashCode());
result = prime * result + ((referenceToken == null) ? 0 : referenceToken.hashCode());
result = prime * result + ((userAgent == null) ? 0 : userAgent.hashCode());
return result;
}
/**
* Method to ensure {@link #equals(Object)} is correct.
*
*
* Note: see this article: canEqual()
*
* @param other
* another object.
* @return true if the other object is an instance of the class in which canEqual is (re)defined, false otherwise.
*/
protected boolean canEqual(Object other) {
return other instanceof ActiveSession;
}
/**
* Indicates whether some other object is "equal to" this one.
*
*
*
* @see java.lang.Object#equals(java.lang.Object)
* @param obj
* an object to compare with this instance.
* @return true if this object is the same as the obj argument; false otherwise.
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ActiveSession)) {
return false;
}
final ActiveSession other = (ActiveSession) obj;
if (!other.canEqual(this)) {
return false;
}
if (accountId == null) {
if (other.accountId != null) {
return false;
}
} else if (!accountId.equals(other.accountId)) {
return false;
}
if (ipAddress == null) {
if (other.ipAddress != null) {
return false;
}
} else if (!ipAddress.equals(other.ipAddress)) {
return false;
}
if (loginTime == null) {
if (other.loginTime != null) {
return false;
}
} else if (!loginTime.equals(other.loginTime)) {
return false;
}
if (referenceToken == null) {
if (other.referenceToken != null) {
return false;
}
} else if (!referenceToken.equals(other.referenceToken)) {
return false;
}
if (userAgent == null) {
if (other.userAgent != null) {
return false;
}
} else if (!userAgent.equals(other.userAgent)) {
return false;
}
return true;
}
/**
* Checks whether the model is valid or not.
*
*
*
* @see SdkModel#isValid()
* @return true if the model is valid; false otherwise.
*/
@Override
public boolean isValid() {
return true;
}
/**
* Clones this instance.
*
*
*
* @see java.lang.Object#clone()
* @return a cloned instance
*/
@Override
public ActiveSession clone() {
return new ActiveSession(this);
}
}