001
014
015 package com.liferay.portlet.softwarecatalog.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
021 import com.liferay.portlet.softwarecatalog.model.SCLicense;
022
023 import java.io.Externalizable;
024 import java.io.IOException;
025 import java.io.ObjectInput;
026 import java.io.ObjectOutput;
027
028
035 public class SCLicenseCacheModel implements CacheModel<SCLicense>,
036 Externalizable {
037 @Override
038 public String toString() {
039 StringBundler sb = new StringBundler(13);
040
041 sb.append("{licenseId=");
042 sb.append(licenseId);
043 sb.append(", name=");
044 sb.append(name);
045 sb.append(", url=");
046 sb.append(url);
047 sb.append(", openSource=");
048 sb.append(openSource);
049 sb.append(", active=");
050 sb.append(active);
051 sb.append(", recommended=");
052 sb.append(recommended);
053 sb.append("}");
054
055 return sb.toString();
056 }
057
058 @Override
059 public SCLicense toEntityModel() {
060 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
061
062 scLicenseImpl.setLicenseId(licenseId);
063
064 if (name == null) {
065 scLicenseImpl.setName(StringPool.BLANK);
066 }
067 else {
068 scLicenseImpl.setName(name);
069 }
070
071 if (url == null) {
072 scLicenseImpl.setUrl(StringPool.BLANK);
073 }
074 else {
075 scLicenseImpl.setUrl(url);
076 }
077
078 scLicenseImpl.setOpenSource(openSource);
079 scLicenseImpl.setActive(active);
080 scLicenseImpl.setRecommended(recommended);
081
082 scLicenseImpl.resetOriginalValues();
083
084 return scLicenseImpl;
085 }
086
087 @Override
088 public void readExternal(ObjectInput objectInput) throws IOException {
089 licenseId = objectInput.readLong();
090 name = objectInput.readUTF();
091 url = objectInput.readUTF();
092 openSource = objectInput.readBoolean();
093 active = objectInput.readBoolean();
094 recommended = objectInput.readBoolean();
095 }
096
097 @Override
098 public void writeExternal(ObjectOutput objectOutput)
099 throws IOException {
100 objectOutput.writeLong(licenseId);
101
102 if (name == null) {
103 objectOutput.writeUTF(StringPool.BLANK);
104 }
105 else {
106 objectOutput.writeUTF(name);
107 }
108
109 if (url == null) {
110 objectOutput.writeUTF(StringPool.BLANK);
111 }
112 else {
113 objectOutput.writeUTF(url);
114 }
115
116 objectOutput.writeBoolean(openSource);
117 objectOutput.writeBoolean(active);
118 objectOutput.writeBoolean(recommended);
119 }
120
121 public long licenseId;
122 public String name;
123 public String url;
124 public boolean openSource;
125 public boolean active;
126 public boolean recommended;
127 }