// Copyright (c) 2011, Chute Corporation. All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of the Chute Corporation nor the names // of its contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // OF THE POSSIBILITY OF SUCH DAMAGE. // package com.chute.sdk.v2.model; import android.os.Parcel; import android.os.Parcelable; import com.fasterxml.jackson.annotation.JsonProperty; /** * The {@link HeartModel} class represents a concept of asset heart. * <p> * Each heart consists of: links, date of creation and update, identifier, asset * ID and album ID the flag belongs to. * */ public class HeartModel implements Parcelable { public static final String TAG = HeartModel.class.getSimpleName(); /** * Unique identifier. */ @JsonProperty("id") private String id; /** * Heart links. */ @JsonProperty("links") private LinkModel links; /** * Date and time of creation. */ @JsonProperty("created_at") private String createdAt; /** * Date and time of update. */ @JsonProperty("updated_at") private String updatedAt; /** * Heart identifier. */ @JsonProperty("identifier") private String identifier; /** * Album that holds the hearted asset. */ @JsonProperty("album_id") private String albumId; /** * Asset the heart belongs to. */ @JsonProperty("asset_id") private String assetId; /** * Number of hearts per asset. */ @JsonProperty("count") private int count; /** * Default non-args constructor. */ public HeartModel() { } /** * Getters and setters. */ public String getId() { return id; } public void setId(String id) { this.id = id; } public LinkModel getLinks() { return links; } public void setLinks(LinkModel links) { this.links = links; } public String getCreatedAt() { return createdAt; } public void setCreatedAt(String createdAt) { this.createdAt = createdAt; } public String getUpdatedAt() { return updatedAt; } public void setUpdatedAt(String updatedAt) { this.updatedAt = updatedAt; } public String getIdentifier() { return identifier; } public void setIdentifier(String identifier) { this.identifier = identifier; } public String getAlbumId() { return albumId; } public void setAlbumId(String albumId) { this.albumId = albumId; } public String getAssetId() { return assetId; } public void setAssetId(String assetId) { this.assetId = assetId; } public int getCount() { return count; } public void setCount(int count) { this.count = count; } public HeartModel(Parcel in) { id = in.readString(); links = in.readParcelable(LinkModel.class.getClassLoader()); createdAt = in.readString(); updatedAt = in.readString(); identifier = in.readString(); albumId = in.readString(); assetId = in.readString(); count = in.readInt(); } /* * (non-Javadoc) * * @see android.os.Parcelable#describeContents() */ @Override public int describeContents() { return 0; } /* * (non-Javadoc) * * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int) */ @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(id); dest.writeParcelable(links, flags); dest.writeString(createdAt); dest.writeString(updatedAt); dest.writeString(identifier); dest.writeString(albumId); dest.writeString(assetId); dest.writeInt(count); } public static final Creator<HeartModel> CREATOR = new Creator<HeartModel>() { @Override public HeartModel createFromParcel(Parcel in) { return new HeartModel(in); } @Override public HeartModel[] newArray(int size) { return new HeartModel[size]; } }; @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((albumId == null) ? 0 : albumId.hashCode()); result = prime * result + ((assetId == null) ? 0 : assetId.hashCode()); result = prime * result + count; result = prime * result + ((createdAt == null) ? 0 : createdAt.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); result = prime * result + ((links == null) ? 0 : links.hashCode()); result = prime * result + ((updatedAt == null) ? 0 : updatedAt.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HeartModel other = (HeartModel) obj; if (albumId == null) { if (other.albumId != null) return false; } else if (!albumId.equals(other.albumId)) return false; if (assetId == null) { if (other.assetId != null) return false; } else if (!assetId.equals(other.assetId)) return false; if (count != other.count) return false; if (createdAt == null) { if (other.createdAt != null) return false; } else if (!createdAt.equals(other.createdAt)) return false; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (identifier == null) { if (other.identifier != null) return false; } else if (!identifier.equals(other.identifier)) return false; if (links == null) { if (other.links != null) return false; } else if (!links.equals(other.links)) return false; if (updatedAt == null) { if (other.updatedAt != null) return false; } else if (!updatedAt.equals(other.updatedAt)) return false; return true; } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("FlagModel [id="); builder.append(id); builder.append(", links="); builder.append(links); builder.append(", createdAt="); builder.append(createdAt); builder.append(", updatedAt="); builder.append(updatedAt); builder.append(", identifier="); builder.append(identifier); builder.append(", albumId="); builder.append(albumId); builder.append(", assetId="); builder.append(assetId); builder.append(", count="); builder.append(count); builder.append("]"); return builder.toString(); } }