com.arm.mbed.cloud.sdk.deviceupdate.model.AbstractUpdateCampaign 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 abstract class. Do not modify its contents.
// Code customisation should happen in the child class [UpdateCampaign]
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.annotations.Required;
import com.arm.mbed.cloud.sdk.common.SdkModel;
import java.util.Date;
/**
* Model for an update campaign.
*/
@Preamble(description = "Model for an update campaign.")
@SuppressWarnings("PMD.CyclomaticComplexity")
public abstract class AbstractUpdateCampaign implements SdkModel {
/**
* Serialisation Id.
*/
private static final long serialVersionUID = -131142121920181L;
/**
* Text description of why a campaign failed to start or why a campaign stopped.
*/
protected final String autostopReason;
/**
* The time the update campaign was created.
*/
protected final Date createdAt;
/**
* An optional description of the campaign.
*/
protected String description;
/**
* The filter for the devices the campaign is targeting at.
*/
@Required
protected String deviceFilter;
/**
* The campaign finish timestamp.
*/
protected final Date finished;
/**
* The campaign ID.
*/
protected String id;
/**
* The campaign name.
*/
protected String name;
/**
* The current phase of the campaign.
*/
protected final String phase;
/**
* value.
*/
protected String rootManifestId;
/**
* value.
*/
protected final String rootManifestUrl;
/**
* value.
*/
protected final Date startedAt;
/**
* The time the object was updated.
*/
protected final Date updatedAt;
/**
* The scheduled start time for the campaign. The campaign will start within 1 minute when then start time has
* elapsed.
*/
protected Date when;
/**
* Internal constructor.
*
*
* Constructor based on all fields.
*
* Note: Should not be used. Use {@link #AbstractUpdateCampaign()} instead.
*
* @param autostopReason
* Text description of why a campaign failed to start or why a campaign stopped.
* @param createdAt
* The time the update campaign was created.
* @param description
* An optional description of the campaign.
* @param deviceFilter
* The filter for the devices the campaign is targeting at.
* @param finished
* The campaign finish timestamp.
* @param id
* The campaign ID.
* @param name
* The campaign name.
* @param phase
* The current phase of the campaign.
* @param rootManifestId
* value.
* @param rootManifestUrl
* value.
* @param startedAt
* value.
* @param updatedAt
* The time the object was updated.
* @param when
* The scheduled start time for the campaign. The campaign will start within 1 minute when then start
* time has elapsed.
*/
@Internal
@SuppressWarnings("PMD.CyclomaticComplexity")
public AbstractUpdateCampaign(String autostopReason, Date createdAt, String description, String deviceFilter,
Date finished, String id, String name, String phase, String rootManifestId,
String rootManifestUrl, Date startedAt, Date updatedAt, Date when) {
super();
this.autostopReason = autostopReason;
this.createdAt = createdAt;
this.finished = finished;
this.phase = phase;
this.rootManifestUrl = rootManifestUrl;
this.startedAt = startedAt;
this.updatedAt = updatedAt;
setDescription(description);
setDeviceFilter(deviceFilter);
setId(id);
setName(name);
setRootManifestId(rootManifestId);
setWhen(when);
}
/**
* Internal constructor.
*
*
* Constructor based on a similar object.
*
* Note: Should not be used. Use {@link #AbstractUpdateCampaign()} instead.
*
* @param abstractUpdateCampaign
* an abstract update campaign.
*/
@Internal
public AbstractUpdateCampaign(AbstractUpdateCampaign abstractUpdateCampaign) {
this(abstractUpdateCampaign == null ? (String) null : abstractUpdateCampaign.autostopReason,
abstractUpdateCampaign == null ? new Date() : abstractUpdateCampaign.createdAt,
abstractUpdateCampaign == null ? (String) null : abstractUpdateCampaign.description,
abstractUpdateCampaign == null ? (String) null : abstractUpdateCampaign.deviceFilter,
abstractUpdateCampaign == null ? new Date() : abstractUpdateCampaign.finished,
abstractUpdateCampaign == null ? (String) null : abstractUpdateCampaign.id,
abstractUpdateCampaign == null ? (String) null : abstractUpdateCampaign.name,
abstractUpdateCampaign == null ? (String) null : abstractUpdateCampaign.phase,
abstractUpdateCampaign == null ? (String) null : abstractUpdateCampaign.rootManifestId,
abstractUpdateCampaign == null ? (String) null : abstractUpdateCampaign.rootManifestUrl,
abstractUpdateCampaign == null ? new Date() : abstractUpdateCampaign.startedAt,
abstractUpdateCampaign == null ? new Date() : abstractUpdateCampaign.updatedAt,
abstractUpdateCampaign == null ? new Date() : abstractUpdateCampaign.when);
}
/**
* Constructor.
*/
public AbstractUpdateCampaign() {
this((String) null, new Date(), (String) null, (String) null, new Date(), (String) null, (String) null,
(String) null, (String) null, (String) null, new Date(), new Date(), new Date());
}
/**
* Constructor.
*
*
* Constructor based on object identifier.
*
*
* @param id
* The campaign ID.
*/
public AbstractUpdateCampaign(String id) {
this();
setId(id);
}
/**
* Internal constructor.
*
*
* Constructor based on read-only fields.
*
* Note: Should not be used. Use {@link #AbstractUpdateCampaign()} instead.
*
* @param autostopReason
* Text description of why a campaign failed to start or why a campaign stopped.
* @param createdAt
* The time the update campaign was created.
* @param finished
* The campaign finish timestamp.
* @param phase
* The current phase of the campaign.
* @param rootManifestUrl
* value.
* @param startedAt
* value.
* @param updatedAt
* The time the object was updated.
*/
@Internal
public AbstractUpdateCampaign(String autostopReason, Date createdAt, Date finished, String phase,
String rootManifestUrl, Date startedAt, Date updatedAt) {
this(autostopReason, createdAt, (String) null, (String) null, finished, (String) null, (String) null, phase,
(String) null, rootManifestUrl, startedAt, updatedAt, new Date());
}
/**
* Gets text description of why a campaign failed to start or why a campaign stopped.
*
* @return autostopReason
*/
public String getAutostopReason() {
return autostopReason;
}
/**
* Gets the time the update campaign was created.
*
* @return createdAt
*/
public Date getCreatedAt() {
return createdAt;
}
/**
* Gets an optional description of the campaign.
*
* @return description
*/
public String getDescription() {
return description;
}
/**
* Sets an optional description of the campaign.
*
*
* Note: the length of the string has to be less than or equal to {@code 2000} to be valid
*
* @param description
* An optional description of the campaign.
*/
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 filter for the devices the campaign is targeting at.
*
* @return deviceFilter
*/
public String getDeviceFilter() {
return deviceFilter;
}
/**
* Sets the filter for the devices the campaign is targeting at.
*
* @param deviceFilter
* The filter for the devices the campaign is targeting at.
*/
@Required
public void setDeviceFilter(String deviceFilter) {
this.deviceFilter = deviceFilter;
}
/**
* Checks whether deviceFilter value is valid.
*
* @return true if the value is valid; false otherwise.
*/
@SuppressWarnings("PMD.UselessParentheses")
public boolean isDeviceFilterValid() {
return deviceFilter != null;
}
/**
* Gets the campaign finish timestamp.
*
* @return finished
*/
public Date getFinished() {
return finished;
}
/**
* Gets the campaign id.
*
* @return id
*/
@Override
public String getId() {
return id;
}
/**
* Sets the campaign id.
*
* @param id
* The campaign ID.
*/
@Override
public void setId(String id) {
this.id = id;
}
/**
* Sets the campaign id.
*
*
* Similar to {@link #setId(String)}
*
* @param updateCampaignId
* The campaign ID.
*/
@Internal
public void setUpdateCampaignId(String updateCampaignId) {
setId(updateCampaignId);
}
/**
* Gets the campaign name.
*
* @return name
*/
public String getName() {
return name;
}
/**
* Sets the campaign name.
*
*
* Note: the length of the string has to be less than or equal to {@code 128} to be valid
*
* @param name
* The campaign 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 current phase of the campaign.
*
* @return phase
*/
public String getPhase() {
return phase;
}
/**
* Gets value.
*
* @return rootManifestId
*/
public String getRootManifestId() {
return rootManifestId;
}
/**
* Sets value.
*
* @param rootManifestId
* value.
*/
public void setRootManifestId(String rootManifestId) {
this.rootManifestId = rootManifestId;
}
/**
* Gets value.
*
* @return rootManifestUrl
*/
public String getRootManifestUrl() {
return rootManifestUrl;
}
/**
* Gets value.
*
* @return startedAt
*/
public Date getStartedAt() {
return startedAt;
}
/**
* Gets the time the object was updated.
*
* @return updatedAt
*/
public Date getUpdatedAt() {
return updatedAt;
}
/**
* Gets the scheduled start time for the campaign. the campaign will start within 1 minute when then start time has
* elapsed.
*
* @return when
*/
public Date getWhen() {
return when;
}
/**
* Sets the scheduled start time for the campaign. the campaign will start within 1 minute when then start time has
* elapsed.
*
* @param when
* The scheduled start time for the campaign. The campaign will start within 1 minute when then start
* time has elapsed.
*/
public void setWhen(Date when) {
this.when = when;
}
/**
* 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 AbstractUpdateCampaign;
}
/**
* 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 "AbstractUpdateCampaign [autostopReason=" + autostopReason + ", createdAt=" + createdAt
+ ", description=" + description + ", deviceFilter=" + deviceFilter + ", finished=" + finished + ", id="
+ id + ", name=" + name + ", phase=" + phase + ", rootManifestId=" + rootManifestId
+ ", rootManifestUrl=" + rootManifestUrl + ", startedAt=" + startedAt + ", updatedAt=" + updatedAt
+ ", when=" + when + "]";
}
/**
* 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 + ((autostopReason == null) ? 0 : autostopReason.hashCode());
result = prime * result + ((createdAt == null) ? 0 : createdAt.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((deviceFilter == null) ? 0 : deviceFilter.hashCode());
result = prime * result + ((finished == null) ? 0 : finished.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((phase == null) ? 0 : phase.hashCode());
result = prime * result + ((rootManifestId == null) ? 0 : rootManifestId.hashCode());
result = prime * result + ((rootManifestUrl == null) ? 0 : rootManifestUrl.hashCode());
result = prime * result + ((startedAt == null) ? 0 : startedAt.hashCode());
result = prime * result + ((updatedAt == null) ? 0 : updatedAt.hashCode());
result = prime * result + ((when == null) ? 0 : when.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 AbstractUpdateCampaign)) {
return false;
}
final AbstractUpdateCampaign other = (AbstractUpdateCampaign) obj;
if (!other.canEqual(this)) {
return false;
}
if (autostopReason == null) {
if (other.autostopReason != null) {
return false;
}
} else if (!autostopReason.equals(other.autostopReason)) {
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 (deviceFilter == null) {
if (other.deviceFilter != null) {
return false;
}
} else if (!deviceFilter.equals(other.deviceFilter)) {
return false;
}
if (finished == null) {
if (other.finished != null) {
return false;
}
} else if (!finished.equals(other.finished)) {
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 (phase == null) {
if (other.phase != null) {
return false;
}
} else if (!phase.equals(other.phase)) {
return false;
}
if (rootManifestId == null) {
if (other.rootManifestId != null) {
return false;
}
} else if (!rootManifestId.equals(other.rootManifestId)) {
return false;
}
if (rootManifestUrl == null) {
if (other.rootManifestUrl != null) {
return false;
}
} else if (!rootManifestUrl.equals(other.rootManifestUrl)) {
return false;
}
if (startedAt == null) {
if (other.startedAt != null) {
return false;
}
} else if (!startedAt.equals(other.startedAt)) {
return false;
}
if (updatedAt == null) {
if (other.updatedAt != null) {
return false;
}
} else if (!updatedAt.equals(other.updatedAt)) {
return false;
}
if (when == null) {
if (other.when != null) {
return false;
}
} else if (!when.equals(other.when)) {
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() && isDeviceFilterValid() && isNameValid();
}
}