001    /**
002     * Copyright (c) 2000-2012 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.portal.model.impl;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    import com.liferay.portal.model.ClassName;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    /**
028     * The cache model class for representing ClassName in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see ClassName
032     * @generated
033     */
034    public class ClassNameCacheModel implements CacheModel<ClassName>,
035            Externalizable {
036            @Override
037            public String toString() {
038                    StringBundler sb = new StringBundler(5);
039    
040                    sb.append("{classNameId=");
041                    sb.append(classNameId);
042                    sb.append(", value=");
043                    sb.append(value);
044                    sb.append("}");
045    
046                    return sb.toString();
047            }
048    
049            public ClassName toEntityModel() {
050                    ClassNameImpl classNameImpl = new ClassNameImpl();
051    
052                    classNameImpl.setClassNameId(classNameId);
053    
054                    if (value == null) {
055                            classNameImpl.setValue(StringPool.BLANK);
056                    }
057                    else {
058                            classNameImpl.setValue(value);
059                    }
060    
061                    classNameImpl.resetOriginalValues();
062    
063                    return classNameImpl;
064            }
065    
066            public void readExternal(ObjectInput objectInput) throws IOException {
067                    classNameId = objectInput.readLong();
068                    value = objectInput.readUTF();
069            }
070    
071            public void writeExternal(ObjectOutput objectOutput)
072                    throws IOException {
073                    objectOutput.writeLong(classNameId);
074    
075                    if (value == null) {
076                            objectOutput.writeUTF(StringPool.BLANK);
077                    }
078                    else {
079                            objectOutput.writeUTF(value);
080                    }
081            }
082    
083            public long classNameId;
084            public String value;
085    }