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.model.CacheModel;
022    
023    import com.liferay.portlet.announcements.model.AnnouncementsFlag;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    import java.util.Date;
031    
032    /**
033     * The cache model class for representing AnnouncementsFlag in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see AnnouncementsFlag
037     * @generated
038     */
039    @ProviderType
040    public class AnnouncementsFlagCacheModel implements CacheModel<AnnouncementsFlag>,
041            Externalizable {
042            @Override
043            public boolean equals(Object obj) {
044                    if (this == obj) {
045                            return true;
046                    }
047    
048                    if (!(obj instanceof AnnouncementsFlagCacheModel)) {
049                            return false;
050                    }
051    
052                    AnnouncementsFlagCacheModel announcementsFlagCacheModel = (AnnouncementsFlagCacheModel)obj;
053    
054                    if (flagId == announcementsFlagCacheModel.flagId) {
055                            return true;
056                    }
057    
058                    return false;
059            }
060    
061            @Override
062            public int hashCode() {
063                    return HashUtil.hash(0, flagId);
064            }
065    
066            @Override
067            public String toString() {
068                    StringBundler sb = new StringBundler(13);
069    
070                    sb.append("{flagId=");
071                    sb.append(flagId);
072                    sb.append(", companyId=");
073                    sb.append(companyId);
074                    sb.append(", userId=");
075                    sb.append(userId);
076                    sb.append(", createDate=");
077                    sb.append(createDate);
078                    sb.append(", entryId=");
079                    sb.append(entryId);
080                    sb.append(", value=");
081                    sb.append(value);
082                    sb.append("}");
083    
084                    return sb.toString();
085            }
086    
087            @Override
088            public AnnouncementsFlag toEntityModel() {
089                    AnnouncementsFlagImpl announcementsFlagImpl = new AnnouncementsFlagImpl();
090    
091                    announcementsFlagImpl.setFlagId(flagId);
092                    announcementsFlagImpl.setCompanyId(companyId);
093                    announcementsFlagImpl.setUserId(userId);
094    
095                    if (createDate == Long.MIN_VALUE) {
096                            announcementsFlagImpl.setCreateDate(null);
097                    }
098                    else {
099                            announcementsFlagImpl.setCreateDate(new Date(createDate));
100                    }
101    
102                    announcementsFlagImpl.setEntryId(entryId);
103                    announcementsFlagImpl.setValue(value);
104    
105                    announcementsFlagImpl.resetOriginalValues();
106    
107                    return announcementsFlagImpl;
108            }
109    
110            @Override
111            public void readExternal(ObjectInput objectInput) throws IOException {
112                    flagId = objectInput.readLong();
113                    companyId = objectInput.readLong();
114                    userId = objectInput.readLong();
115                    createDate = objectInput.readLong();
116                    entryId = objectInput.readLong();
117                    value = objectInput.readInt();
118            }
119    
120            @Override
121            public void writeExternal(ObjectOutput objectOutput)
122                    throws IOException {
123                    objectOutput.writeLong(flagId);
124                    objectOutput.writeLong(companyId);
125                    objectOutput.writeLong(userId);
126                    objectOutput.writeLong(createDate);
127                    objectOutput.writeLong(entryId);
128                    objectOutput.writeInt(value);
129            }
130    
131            public long flagId;
132            public long companyId;
133            public long userId;
134            public long createDate;
135            public long entryId;
136            public int value;
137    }