com.arm.mbed.cloud.sdk.deviceupdate.model.FirmwareImage Maven / Gradle / Ivy
Show all versions of foundation-models Show documentation
// 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.deviceupdate.model;
import com.arm.mbed.cloud.sdk.annotations.Internal;
import com.arm.mbed.cloud.sdk.annotations.Preamble;
import com.arm.mbed.cloud.sdk.common.SdkModel;
import java.util.Date;
import java.util.Hashtable;
import java.util.Map;
import java.util.Objects;
/**
* Model for a firmware image.
*/
@Preamble(description = "Model for a firmware image.")
@SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.AvoidDuplicateLiterals" })
public class FirmwareImage implements SdkModel {
/**
* Mapping needed for encoding or decoding filters.
*
*
* Filters are used when listing models. See {@link com.arm.mbed.cloud.sdk.common.listing.filtering.Filters}
*/
@Internal
public static final Map FILTER_MAPPING = generateFilterMapping();
/**
* Serialisation Id.
*/
private static final long serialVersionUID = 4431926369181323L;
/**
* The time the object was created.
*/
private final Date createdAt;
/**
* The checksum (sha256) generated for the datafile.
*/
private final String datafileChecksum;
/**
* The size of the datafile in bytes.
*/
private final long datafileSize;
/**
* The firmware image file URL.
*/
private final String datafileUrl;
/**
* The description of the object.
*/
private String description;
/**
* The firmware image ID.
*/
private String id;
/**
* The firmware image name.
*/
private String name;
/**
* The time the object was updated.
*/
private final Date updatedAt;
/**
* Internal constructor.
*
*
* Constructor based on all fields.
*
* Note: Should not be used. Use {@link #FirmwareImage()} instead.
*
* @param createdAt
* The time the object was created.
* @param datafileChecksum
* The checksum (sha256) generated for the datafile.
* @param datafileSize
* The size of the datafile in bytes.
* @param datafileUrl
* The firmware image file URL.
* @param description
* The description of the object.
* @param id
* The firmware image ID.
* @param name
* The firmware image name.
* @param updatedAt
* The time the object was updated.
*/
@Internal
@SuppressWarnings("PMD.CyclomaticComplexity")
public FirmwareImage(Date createdAt, String datafileChecksum, long datafileSize, String datafileUrl,
String description, String id, String name, Date updatedAt) {
super();
this.createdAt = createdAt;
this.datafileChecksum = datafileChecksum;
this.datafileSize = datafileSize;
this.datafileUrl = datafileUrl;
this.updatedAt = updatedAt;
setDescription(description);
setId(id);
setName(name);
}
/**
* Internal constructor.
*
*
* Constructor based on a similar object.
*
* Note: Should not be used. Use {@link #FirmwareImage()} instead.
*
* @param firmwareImage
* a firmware image.
*/
@Internal
public FirmwareImage(FirmwareImage firmwareImage) {
this(firmwareImage == null ? new Date() : firmwareImage.createdAt,
firmwareImage == null ? (String) null : firmwareImage.datafileChecksum,
firmwareImage == null ? 0 : firmwareImage.datafileSize,
firmwareImage == null ? (String) null : firmwareImage.datafileUrl,
firmwareImage == null ? (String) null : firmwareImage.description,
firmwareImage == null ? (String) null : firmwareImage.id,
firmwareImage == null ? (String) null : firmwareImage.name,
firmwareImage == null ? new Date() : firmwareImage.updatedAt);
}
/**
* Constructor.
*/
public FirmwareImage() {
this(new Date(), (String) null, 0, (String) null, (String) null, (String) null, (String) null, new Date());
}
/**
* Constructor.
*
*
* Constructor based on object identifier.
*
*
* @param id
* The firmware image ID.
*/
public FirmwareImage(String id) {
this();
setId(id);
}
/**
* Internal constructor.
*
*
* Constructor based on read-only fields.
*
* Note: Should not be used. Use {@link #FirmwareImage()} instead.
*
* @param createdAt
* The time the object was created.
* @param datafileChecksum
* The checksum (sha256) generated for the datafile.
* @param datafileSize
* The size of the datafile in bytes.
* @param datafileUrl
* The firmware image file URL.
* @param updatedAt
* The time the object was updated.
*/
@Internal
public FirmwareImage(Date createdAt, String datafileChecksum, long datafileSize, String datafileUrl,
Date updatedAt) {
this(createdAt, datafileChecksum, datafileSize, datafileUrl, (String) null, (String) null, (String) null,
updatedAt);
}
/**
* Gets the time the object was created.
*
* @return createdAt
*/
public Date getCreatedAt() {
return createdAt;
}
/**
* Gets the checksum (sha256) generated for the datafile.
*
* @return datafileChecksum
*/
public String getDatafileChecksum() {
return datafileChecksum;
}
/**
* Gets the size of the datafile in bytes.
*
* @return datafileSize
*/
public long getDatafileSize() {
return datafileSize;
}
/**
* Gets the firmware image file url.
*
* @return datafileUrl
*/
public String getDatafileUrl() {
return datafileUrl;
}
/**
* Gets the description of the object.
*
* @return description
*/
public String getDescription() {
return description;
}
/**
* Sets the description of the object.
*
*
* Note: the length of the string has to be less than or equal to {@code 2000} to be valid
*
* @param description
* The description of the object.
*/
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() <= 2000);
}
/**
* Gets the firmware image id.
*
* @return id
*/
@Override
public String getId() {
return id;
}
/**
* Sets the firmware image id.
*
* @param id
* The firmware image ID.
*/
@Override
public void setId(String id) {
this.id = id;
}
/**
* Sets the firmware image id.
*
*
* Similar to {@link #setId(String)}
*
* @param firmwareImageId
* The firmware image ID.
*/
@Internal
public void setFirmwareImageId(String firmwareImageId) {
setId(firmwareImageId);
}
/**
* Gets the firmware image name.
*
* @return name
*/
public String getName() {
return name;
}
/**
* Sets the firmware image name.
*
*
* Note: the length of the string has to be less than or equal to {@code 128} to be valid
*
* @param name
* The firmware image name.
*/
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() <= 128);
}
/**
* Gets the time the object was updated.
*
* @return updatedAt
*/
public Date getUpdatedAt() {
return updatedAt;
}
/**
* Method generating the mapping needed for encoding or decoding filters.
*
*
* Filters are used when listing models. See {@link com.arm.mbed.cloud.sdk.common.listing.filtering.Filters}
*
* @return the mapping table
*/
@Internal
protected static final Map generateFilterMapping() {
final Map filterMapping = new Hashtable<>(1);
filterMapping.put("datafileUrl", "datafile");
return filterMapping;
}
/**
* Returns a string representation of the object.
*
*
*
* @see java.lang.Object#toString()
* @return the string representation
*/
@Override
public String toString() {
return "FirmwareImage [createdAt=" + createdAt + ", datafileChecksum=" + datafileChecksum + ", datafileSize="
+ datafileSize + ", datafileUrl=" + datafileUrl + ", description=" + description + ", id=" + id
+ ", name=" + name + ", updatedAt=" + updatedAt + "]";
}
/**
* 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 + ((createdAt == null) ? 0 : createdAt.hashCode());
result = prime * result + ((datafileChecksum == null) ? 0 : datafileChecksum.hashCode());
result = prime * result + Objects.hashCode(Long.valueOf(datafileSize));
result = prime * result + ((datafileUrl == null) ? 0 : datafileUrl.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((updatedAt == null) ? 0 : updatedAt.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 FirmwareImage;
}
/**
* 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 FirmwareImage)) {
return false;
}
final FirmwareImage other = (FirmwareImage) obj;
if (!other.canEqual(this)) {
return false;
}
if (createdAt == null) {
if (other.createdAt != null) {
return false;
}
} else if (!createdAt.equals(other.createdAt)) {
return false;
}
if (datafileChecksum == null) {
if (other.datafileChecksum != null) {
return false;
}
} else if (!datafileChecksum.equals(other.datafileChecksum)) {
return false;
}
if (datafileSize != other.datafileSize) {
return false;
}
if (datafileUrl == null) {
if (other.datafileUrl != null) {
return false;
}
} else if (!datafileUrl.equals(other.datafileUrl)) {
return false;
}
if (description == null) {
if (other.description != null) {
return false;
}
} else if (!description.equals(other.description)) {
return false;
}
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
if (name == null) {
if (other.name != null) {
return false;
}
} else if (!name.equals(other.name)) {
return false;
}
if (updatedAt == null) {
if (other.updatedAt != null) {
return false;
}
} else if (!updatedAt.equals(other.updatedAt)) {
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 isDescriptionValid() && isNameValid();
}
/**
* Clones this instance.
*
*
*
* @see java.lang.Object#clone()
* @return a cloned instance
*/
@Override
public FirmwareImage clone() {
return new FirmwareImage(this);
}
}