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.StringBundler;
020    import com.liferay.portal.model.CacheModel;
021    
022    import com.liferay.portlet.announcements.model.AnnouncementsFlag;
023    
024    import java.io.Externalizable;
025    import java.io.IOException;
026    import java.io.ObjectInput;
027    import java.io.ObjectOutput;
028    
029    import java.util.Date;
030    
031    /**
032     * The cache model class for representing AnnouncementsFlag in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see AnnouncementsFlag
036     * @generated
037     */
038    @ProviderType
039    public class AnnouncementsFlagCacheModel implements CacheModel<AnnouncementsFlag>,
040            Externalizable {
041            @Override
042            public String toString() {
043                    StringBundler sb = new StringBundler(11);
044    
045                    sb.append("{flagId=");
046                    sb.append(flagId);
047                    sb.append(", userId=");
048                    sb.append(userId);
049                    sb.append(", createDate=");
050                    sb.append(createDate);
051                    sb.append(", entryId=");
052                    sb.append(entryId);
053                    sb.append(", value=");
054                    sb.append(value);
055                    sb.append("}");
056    
057                    return sb.toString();
058            }
059    
060            @Override
061            public AnnouncementsFlag toEntityModel() {
062                    AnnouncementsFlagImpl announcementsFlagImpl = new AnnouncementsFlagImpl();
063    
064                    announcementsFlagImpl.setFlagId(flagId);
065                    announcementsFlagImpl.setUserId(userId);
066    
067                    if (createDate == Long.MIN_VALUE) {
068                            announcementsFlagImpl.setCreateDate(null);
069                    }
070                    else {
071                            announcementsFlagImpl.setCreateDate(new Date(createDate));
072                    }
073    
074                    announcementsFlagImpl.setEntryId(entryId);
075                    announcementsFlagImpl.setValue(value);
076    
077                    announcementsFlagImpl.resetOriginalValues();
078    
079                    return announcementsFlagImpl;
080            }
081    
082            @Override
083            public void readExternal(ObjectInput objectInput) throws IOException {
084                    flagId = objectInput.readLong();
085                    userId = objectInput.readLong();
086                    createDate = objectInput.readLong();
087                    entryId = objectInput.readLong();
088                    value = objectInput.readInt();
089            }
090    
091            @Override
092            public void writeExternal(ObjectOutput objectOutput)
093                    throws IOException {
094                    objectOutput.writeLong(flagId);
095                    objectOutput.writeLong(userId);
096                    objectOutput.writeLong(createDate);
097                    objectOutput.writeLong(entryId);
098                    objectOutput.writeInt(value);
099            }
100    
101            public long flagId;
102            public long userId;
103            public long createDate;
104            public long entryId;
105            public int value;
106    }