
com.arm.mbed.cloud.sdk.security.model.AbstractSubtenantTrustedCertificate Maven / Gradle / Ivy
// This file was generated by the Pelion SDK foundation code generator.
// This is an autogenerated abstract class. Do not modify its contents.
// Code customisation should happen in the child class [SubtenantTrustedCertificate]
package com.arm.mbed.cloud.sdk.security.model;
import com.arm.mbed.cloud.sdk.annotations.Internal;
import com.arm.mbed.cloud.sdk.annotations.Preamble;
import com.arm.mbed.cloud.sdk.annotations.Required;
import com.arm.mbed.cloud.sdk.common.SdkModel;
import java.util.Date;
import java.util.Objects;
/**
* Model for a subtenant trusted certificate.
*/
@Preamble(description = "Model for a subtenant trusted certificate.")
@SuppressWarnings("PMD.CyclomaticComplexity")
public abstract class AbstractSubtenantTrustedCertificate implements SdkModel {
/**
* Serialisation Id.
*/
private static final long serialVersionUID = -167468309812192L;
/**
* The ID of the account.
*/
@Required
protected String accountId;
/**
* X509.v3 trusted certificate in PEM format.
*/
@Required
protected String certificate;
/**
* A SHA-256 fingerprint of the certificate.
*/
protected final String certificateFingerprint;
/**
* Creation UTC time RFC3339.
*/
protected final Date createdAt;
/**
* Human readable description of this certificate.
*/
protected String description;
/**
* Device execution mode where 1 means a developer certificate.
*/
protected final int deviceExecutionMode;
/**
* If true, signature is not required. Default value false.
*/
protected boolean enrollmentMode;
/**
* Entity ID.
*/
protected String id;
/**
* Issuer of the certificate.
*/
protected final String issuer;
/**
* Certificate name.
*/
@Required
protected String name;
/**
* The ID of the owner.
*/
protected final String ownerId;
/**
* Service name where the certificate is used.
*/
@Required
protected SubtenantTrustedCertificateService service;
/**
* Status of the certificate.
*/
protected SubtenantTrustedCertificateStatus status;
/**
* Subject of the certificate.
*/
protected final String subject;
/**
* Last update UTC time RFC3339.
*/
protected final Date updatedAt;
/**
* This read-only flag indicates whether the certificate is valid or not.
*/
protected final boolean valid;
/**
* Expiration time in UTC formatted as RFC3339.
*/
protected final Date validity;
/**
* Internal constructor.
*
*
* Constructor based on all fields.
*
* Note: Should not be used. Use {@link #AbstractSubtenantTrustedCertificate()} instead.
*
* @param accountId
* The ID of the account.
* @param certificate
* X509.v3 trusted certificate in PEM format.
* @param certificateFingerprint
* A SHA-256 fingerprint of the certificate.
* @param createdAt
* Creation UTC time RFC3339.
* @param description
* Human readable description of this certificate.
* @param deviceExecutionMode
* Device execution mode where 1 means a developer certificate.
* @param enrollmentMode
* If true, signature is not required. Default value false.
* @param id
* Entity ID.
* @param issuer
* Issuer of the certificate.
* @param name
* Certificate name.
* @param ownerId
* The ID of the owner.
* @param service
* Service name where the certificate is used.
* @param status
* Status of the certificate.
* @param subject
* Subject of the certificate.
* @param updatedAt
* Last update UTC time RFC3339.
* @param valid
* This read-only flag indicates whether the certificate is valid or not.
* @param validity
* Expiration time in UTC formatted as RFC3339.
*/
@Internal
@SuppressWarnings("PMD.CyclomaticComplexity")
public AbstractSubtenantTrustedCertificate(String accountId, String certificate, String certificateFingerprint,
Date createdAt, String description, int deviceExecutionMode,
boolean enrollmentMode, String id, String issuer, String name,
String ownerId, SubtenantTrustedCertificateService service,
SubtenantTrustedCertificateStatus status, String subject, Date updatedAt,
boolean valid, Date validity) {
super();
this.certificateFingerprint = certificateFingerprint;
this.createdAt = createdAt;
this.deviceExecutionMode = deviceExecutionMode;
this.issuer = issuer;
this.ownerId = ownerId;
this.subject = subject;
this.updatedAt = updatedAt;
this.valid = valid;
this.validity = validity;
setAccountId(accountId);
setCertificate(certificate);
setDescription(description);
setEnrollmentMode(enrollmentMode);
setId(id);
setName(name);
setService(service);
setStatus(status);
}
/**
* Internal constructor.
*
*
* Constructor based on a similar object.
*
* Note: Should not be used. Use {@link #AbstractSubtenantTrustedCertificate()} instead.
*
* @param abstractSubtenantTrustedCertificate
* an abstract subtenant trusted certificate.
*/
@Internal
public AbstractSubtenantTrustedCertificate(AbstractSubtenantTrustedCertificate abstractSubtenantTrustedCertificate) {
this(abstractSubtenantTrustedCertificate == null ? (String) null
: abstractSubtenantTrustedCertificate.accountId,
abstractSubtenantTrustedCertificate == null ? (String) null
: abstractSubtenantTrustedCertificate.certificate,
abstractSubtenantTrustedCertificate == null ? (String) null
: abstractSubtenantTrustedCertificate.certificateFingerprint,
abstractSubtenantTrustedCertificate == null ? new Date() : abstractSubtenantTrustedCertificate.createdAt,
abstractSubtenantTrustedCertificate == null ? (String) null
: abstractSubtenantTrustedCertificate.description,
abstractSubtenantTrustedCertificate == null ? 0 : abstractSubtenantTrustedCertificate.deviceExecutionMode,
abstractSubtenantTrustedCertificate != null && abstractSubtenantTrustedCertificate.enrollmentMode,
abstractSubtenantTrustedCertificate == null ? (String) null : abstractSubtenantTrustedCertificate.id,
abstractSubtenantTrustedCertificate == null ? (String) null : abstractSubtenantTrustedCertificate.issuer,
abstractSubtenantTrustedCertificate == null ? (String) null : abstractSubtenantTrustedCertificate.name,
abstractSubtenantTrustedCertificate == null ? (String) null : abstractSubtenantTrustedCertificate.ownerId,
abstractSubtenantTrustedCertificate == null ? SubtenantTrustedCertificateService.getDefault()
: abstractSubtenantTrustedCertificate.service,
abstractSubtenantTrustedCertificate == null ? SubtenantTrustedCertificateStatus.getDefault()
: abstractSubtenantTrustedCertificate.status,
abstractSubtenantTrustedCertificate == null ? (String) null : abstractSubtenantTrustedCertificate.subject,
abstractSubtenantTrustedCertificate == null ? new Date() : abstractSubtenantTrustedCertificate.updatedAt,
abstractSubtenantTrustedCertificate != null && abstractSubtenantTrustedCertificate.valid,
abstractSubtenantTrustedCertificate == null ? new Date() : abstractSubtenantTrustedCertificate.validity);
}
/**
* Constructor.
*/
public AbstractSubtenantTrustedCertificate() {
this((String) null, (String) null, (String) null, new Date(), (String) null, 0, false, (String) null,
(String) null, (String) null, (String) null, SubtenantTrustedCertificateService.getDefault(),
SubtenantTrustedCertificateStatus.getDefault(), (String) null, new Date(), false, new Date());
}
/**
* Constructor.
*
*
* Constructor based on object identifier.
*
*
* @param id
* Entity ID.
*/
public AbstractSubtenantTrustedCertificate(String id) {
this();
setId(id);
}
/**
* Internal constructor.
*
*
* Constructor based on read-only fields.
*
* Note: Should not be used. Use {@link #AbstractSubtenantTrustedCertificate()} instead.
*
* @param certificateFingerprint
* A SHA-256 fingerprint of the certificate.
* @param createdAt
* Creation UTC time RFC3339.
* @param deviceExecutionMode
* Device execution mode where 1 means a developer certificate.
* @param issuer
* Issuer of the certificate.
* @param ownerId
* The ID of the owner.
* @param subject
* Subject of the certificate.
* @param updatedAt
* Last update UTC time RFC3339.
* @param valid
* This read-only flag indicates whether the certificate is valid or not.
* @param validity
* Expiration time in UTC formatted as RFC3339.
*/
@Internal
@SuppressWarnings("PMD.CyclomaticComplexity")
public AbstractSubtenantTrustedCertificate(String certificateFingerprint, Date createdAt, int deviceExecutionMode,
String issuer, String ownerId, String subject, Date updatedAt,
boolean valid, Date validity) {
this((String) null, (String) null, certificateFingerprint, createdAt, (String) null, deviceExecutionMode, false,
(String) null, issuer, (String) null, ownerId, SubtenantTrustedCertificateService.getDefault(),
SubtenantTrustedCertificateStatus.getDefault(), subject, updatedAt, valid, validity);
}
/**
* Constructor.
*
*
* Constructor based on required fields.
*
*
* @param accountId
* The ID of the account.
* @param certificate
* X509.v3 trusted certificate in PEM format.
* @param name
* Certificate name.
* @param service
* Service name where the certificate is used.
*/
public AbstractSubtenantTrustedCertificate(String accountId, String certificate, String name,
SubtenantTrustedCertificateService service) {
this(accountId, certificate, (String) null, new Date(), (String) null, 0, false, (String) null, (String) null,
name, (String) null, service, SubtenantTrustedCertificateStatus.getDefault(), (String) null, new Date(),
false, new Date());
}
/**
* Gets the id of the account.
*
* @return accountId
*/
public String getAccountId() {
return accountId;
}
/**
* Sets the id of the account.
*
*
* Note: the length of the string has to match {@code /[a-f0-9]{32}/} to be valid
*
* @param accountId
* The ID of the account.
*/
@Required
public void setAccountId(String accountId) {
this.accountId = accountId;
}
/**
* Checks whether accountId value is valid.
*
* @return true if the value is valid; false otherwise.
*/
@SuppressWarnings("PMD.UselessParentheses")
public boolean isAccountIdValid() {
return accountId != null && (accountId.matches("[a-f0-9]{32}"));
}
/**
* Gets x509.v3 trusted certificate in pem format.
*
* @return certificate
*/
public String getCertificate() {
return certificate;
}
/**
* Sets x509.v3 trusted certificate in pem format.
*
* @param certificate
* X509.v3 trusted certificate in PEM format.
*/
@Required
public void setCertificate(String certificate) {
this.certificate = certificate;
}
/**
* Checks whether certificate value is valid.
*
* @return true if the value is valid; false otherwise.
*/
@SuppressWarnings("PMD.UselessParentheses")
public boolean isCertificateValid() {
return certificate != null;
}
/**
* Gets a sha-256 fingerprint of the certificate.
*
* @return certificateFingerprint
*/
public String getCertificateFingerprint() {
return certificateFingerprint;
}
/**
* Gets creation utc time rfc3339.
*
* @return createdAt
*/
public Date getCreatedAt() {
return createdAt;
}
/**
* Gets human readable description of this certificate.
*
* @return description
*/
public String getDescription() {
return description;
}
/**
* Sets human readable description of this certificate.
*
*
* Note: the length of the string has to be less than or equal to {@code 500} to be valid
*
* @param description
* Human readable description of this certificate.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Checks whether description value is valid.
*
* @return true if the value is valid; false otherwise.
*/
@SuppressWarnings("PMD.UselessParentheses")
public boolean isDescriptionValid() {
return (description == null || description.length() <= 500);
}
/**
* Gets device execution mode where 1 means a developer certificate.
*
* @return deviceExecutionMode
*/
public int getDeviceExecutionMode() {
return deviceExecutionMode;
}
/**
* Gets if true, signature is not required. default value false.
*
* @return enrollmentMode
*/
public boolean isEnrollmentMode() {
return enrollmentMode;
}
/**
* Sets if true, signature is not required. default value false.
*
* @param enrollmentMode
* If true, signature is not required. Default value false.
*/
public void setEnrollmentMode(boolean enrollmentMode) {
this.enrollmentMode = enrollmentMode;
}
/**
* Gets entity id.
*
* @return id
*/
@Override
public String getId() {
return id;
}
/**
* Sets entity id.
*
*
* Note: the length of the string has to match {@code /[a-f0-9]{32}/} to be valid
*
* @param id
* Entity ID.
*/
@Override
public void setId(String id) {
this.id = id;
}
/**
* Sets entity id.
*
*
* Similar to {@link #setId(String)}
*
* Note: the length of the string has to match {@code /[a-f0-9]{32}/} to be valid
*
* @param subtenantTrustedCertificateId
* Entity ID.
*/
@Internal
public void setSubtenantTrustedCertificateId(String subtenantTrustedCertificateId) {
setId(subtenantTrustedCertificateId);
}
/**
* Checks whether id value is valid.
*
* @return true if the value is valid; false otherwise.
*/
@SuppressWarnings("PMD.UselessParentheses")
public boolean isIdValid() {
return (id == null || id.matches("[a-f0-9]{32}"));
}
/**
* Gets issuer of the certificate.
*
* @return issuer
*/
public String getIssuer() {
return issuer;
}
/**
* Gets certificate name.
*
* @return name
*/
public String getName() {
return name;
}
/**
* Sets certificate name.
*
*
* Note: the length of the string has to be less than or equal to {@code 100} to be valid
*
* @param name
* Certificate name.
*/
@Required
public void setName(String name) {
this.name = name;
}
/**
* Checks whether name value is valid.
*
* @return true if the value is valid; false otherwise.
*/
@SuppressWarnings("PMD.UselessParentheses")
public boolean isNameValid() {
return name != null && (name.length() <= 100);
}
/**
* Gets the id of the owner.
*
* @return ownerId
*/
public String getOwnerId() {
return ownerId;
}
/**
* Gets service name where the certificate is used.
*
* @return service
*/
public SubtenantTrustedCertificateService getService() {
return service;
}
/**
* Sets service name where the certificate is used.
*
* @param service
* Service name where the certificate is used.
*/
@Required
public void setService(SubtenantTrustedCertificateService service) {
this.service = service;
}
/**
* Sets service name where the certificate is used.
*
*
* Similar to {@link #setService(com.arm.mbed.cloud.sdk.security.model.SubtenantTrustedCertificateService)}
*
* @param service
* Service name where the certificate is used.
*/
@Internal
@Required
public void setService(String service) {
this.service = SubtenantTrustedCertificateService.getValue(service);
}
/**
* Checks whether service value is valid.
*
* @return true if the value is valid; false otherwise.
*/
@SuppressWarnings("PMD.UselessParentheses")
public boolean isServiceValid() {
return service != null;
}
/**
* Gets status of the certificate.
*
* @return status
*/
public SubtenantTrustedCertificateStatus getStatus() {
return status;
}
/**
* Sets status of the certificate.
*
* @param status
* Status of the certificate.
*/
public void setStatus(SubtenantTrustedCertificateStatus status) {
this.status = status;
}
/**
* Sets status of the certificate.
*
*
* Similar to {@link #setStatus(com.arm.mbed.cloud.sdk.security.model.SubtenantTrustedCertificateStatus)}
*
* @param status
* Status of the certificate.
*/
@Internal
public void setStatus(String status) {
this.status = SubtenantTrustedCertificateStatus.getValue(status);
}
/**
* Gets subject of the certificate.
*
* @return subject
*/
public String getSubject() {
return subject;
}
/**
* Gets last update utc time rfc3339.
*
* @return updatedAt
*/
public Date getUpdatedAt() {
return updatedAt;
}
/**
* Gets expiration time in utc formatted as rfc3339.
*
* @return validity
*/
public Date getValidity() {
return validity;
}
/**
* 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 AbstractSubtenantTrustedCertificate;
}
/**
* Clones this instance.
*
*
*
* @see java.lang.Object#clone()
* @return a cloned instance
*/
@Override
public abstract Object clone();
/**
* Returns a string representation of the object.
*
*
*
* @see java.lang.Object#toString()
* @return the string representation
*/
@Override
public String toString() {
return "AbstractSubtenantTrustedCertificate [accountId=" + accountId + ", certificate=" + certificate
+ ", certificateFingerprint=" + certificateFingerprint + ", createdAt=" + createdAt + ", description="
+ description + ", deviceExecutionMode=" + deviceExecutionMode + ", enrollmentMode=" + enrollmentMode
+ ", id=" + id + ", issuer=" + issuer + ", name=" + name + ", ownerId=" + ownerId + ", service="
+ service + ", status=" + status + ", subject=" + subject + ", updatedAt=" + updatedAt + ", valid="
+ valid + ", validity=" + validity + "]";
}
/**
* 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 + ((certificate == null) ? 0 : certificate.hashCode());
result = prime * result + ((certificateFingerprint == null) ? 0 : certificateFingerprint.hashCode());
result = prime * result + ((createdAt == null) ? 0 : createdAt.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + Objects.hashCode(Integer.valueOf(deviceExecutionMode));
result = prime * result + Objects.hashCode(Boolean.valueOf(enrollmentMode));
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((issuer == null) ? 0 : issuer.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((ownerId == null) ? 0 : ownerId.hashCode());
result = prime * result + ((service == null) ? 0 : service.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
result = prime * result + ((subject == null) ? 0 : subject.hashCode());
result = prime * result + ((updatedAt == null) ? 0 : updatedAt.hashCode());
result = prime * result + Objects.hashCode(Boolean.valueOf(valid));
result = prime * result + ((validity == null) ? 0 : validity.hashCode());
return result;
}
/**
* 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
@SuppressWarnings({ "PMD.ExcessiveMethodLength", "PMD.NcssMethodCount" })
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AbstractSubtenantTrustedCertificate)) {
return false;
}
final AbstractSubtenantTrustedCertificate other = (AbstractSubtenantTrustedCertificate) 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 (certificate == null) {
if (other.certificate != null) {
return false;
}
} else if (!certificate.equals(other.certificate)) {
return false;
}
if (certificateFingerprint == null) {
if (other.certificateFingerprint != null) {
return false;
}
} else if (!certificateFingerprint.equals(other.certificateFingerprint)) {
return false;
}
if (createdAt == null) {
if (other.createdAt != null) {
return false;
}
} else if (!createdAt.equals(other.createdAt)) {
return false;
}
if (description == null) {
if (other.description != null) {
return false;
}
} else if (!description.equals(other.description)) {
return false;
}
if (deviceExecutionMode != other.deviceExecutionMode) {
return false;
}
if (enrollmentMode != other.enrollmentMode) {
return false;
}
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
if (issuer == null) {
if (other.issuer != null) {
return false;
}
} else if (!issuer.equals(other.issuer)) {
return false;
}
if (name == null) {
if (other.name != null) {
return false;
}
} else if (!name.equals(other.name)) {
return false;
}
if (ownerId == null) {
if (other.ownerId != null) {
return false;
}
} else if (!ownerId.equals(other.ownerId)) {
return false;
}
if (service != other.service) {
return false;
}
if (status != other.status) {
return false;
}
if (subject == null) {
if (other.subject != null) {
return false;
}
} else if (!subject.equals(other.subject)) {
return false;
}
if (updatedAt == null) {
if (other.updatedAt != null) {
return false;
}
} else if (!updatedAt.equals(other.updatedAt)) {
return false;
}
if (valid != other.valid) {
return false;
}
if (validity == null) {
if (other.validity != null) {
return false;
}
} else if (!validity.equals(other.validity)) {
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 isAccountIdValid() && isCertificateValid() && isDescriptionValid() && isIdValid() && isNameValid()
&& isServiceValid();
}
}