001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.announcements.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.util.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    
024    import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    /**
032     * The cache model class for representing AnnouncementsDelivery in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see AnnouncementsDelivery
036     * @generated
037     */
038    @ProviderType
039    public class AnnouncementsDeliveryCacheModel implements CacheModel<AnnouncementsDelivery>,
040            Externalizable {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof AnnouncementsDeliveryCacheModel)) {
048                            return false;
049                    }
050    
051                    AnnouncementsDeliveryCacheModel announcementsDeliveryCacheModel = (AnnouncementsDeliveryCacheModel)obj;
052    
053                    if (deliveryId == announcementsDeliveryCacheModel.deliveryId) {
054                            return true;
055                    }
056    
057                    return false;
058            }
059    
060            @Override
061            public int hashCode() {
062                    return HashUtil.hash(0, deliveryId);
063            }
064    
065            @Override
066            public String toString() {
067                    StringBundler sb = new StringBundler(15);
068    
069                    sb.append("{deliveryId=");
070                    sb.append(deliveryId);
071                    sb.append(", companyId=");
072                    sb.append(companyId);
073                    sb.append(", userId=");
074                    sb.append(userId);
075                    sb.append(", type=");
076                    sb.append(type);
077                    sb.append(", email=");
078                    sb.append(email);
079                    sb.append(", sms=");
080                    sb.append(sms);
081                    sb.append(", website=");
082                    sb.append(website);
083                    sb.append("}");
084    
085                    return sb.toString();
086            }
087    
088            @Override
089            public AnnouncementsDelivery toEntityModel() {
090                    AnnouncementsDeliveryImpl announcementsDeliveryImpl = new AnnouncementsDeliveryImpl();
091    
092                    announcementsDeliveryImpl.setDeliveryId(deliveryId);
093                    announcementsDeliveryImpl.setCompanyId(companyId);
094                    announcementsDeliveryImpl.setUserId(userId);
095    
096                    if (type == null) {
097                            announcementsDeliveryImpl.setType(StringPool.BLANK);
098                    }
099                    else {
100                            announcementsDeliveryImpl.setType(type);
101                    }
102    
103                    announcementsDeliveryImpl.setEmail(email);
104                    announcementsDeliveryImpl.setSms(sms);
105                    announcementsDeliveryImpl.setWebsite(website);
106    
107                    announcementsDeliveryImpl.resetOriginalValues();
108    
109                    return announcementsDeliveryImpl;
110            }
111    
112            @Override
113            public void readExternal(ObjectInput objectInput) throws IOException {
114                    deliveryId = objectInput.readLong();
115                    companyId = objectInput.readLong();
116                    userId = objectInput.readLong();
117                    type = objectInput.readUTF();
118                    email = objectInput.readBoolean();
119                    sms = objectInput.readBoolean();
120                    website = objectInput.readBoolean();
121            }
122    
123            @Override
124            public void writeExternal(ObjectOutput objectOutput)
125                    throws IOException {
126                    objectOutput.writeLong(deliveryId);
127                    objectOutput.writeLong(companyId);
128                    objectOutput.writeLong(userId);
129    
130                    if (type == null) {
131                            objectOutput.writeUTF(StringPool.BLANK);
132                    }
133                    else {
134                            objectOutput.writeUTF(type);
135                    }
136    
137                    objectOutput.writeBoolean(email);
138                    objectOutput.writeBoolean(sms);
139                    objectOutput.writeBoolean(website);
140            }
141    
142            public long deliveryId;
143            public long companyId;
144            public long userId;
145            public String type;
146            public boolean email;
147            public boolean sms;
148            public boolean website;
149    }