001
014
015 package com.liferay.portlet.softwarecatalog.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.softwarecatalog.model.SCLicense;
025
026 import java.io.Externalizable;
027 import java.io.IOException;
028 import java.io.ObjectInput;
029 import java.io.ObjectOutput;
030
031
038 @ProviderType
039 public class SCLicenseCacheModel implements CacheModel<SCLicense>,
040 Externalizable {
041 @Override
042 public boolean equals(Object obj) {
043 if (this == obj) {
044 return true;
045 }
046
047 if (!(obj instanceof SCLicenseCacheModel)) {
048 return false;
049 }
050
051 SCLicenseCacheModel scLicenseCacheModel = (SCLicenseCacheModel)obj;
052
053 if (licenseId == scLicenseCacheModel.licenseId) {
054 return true;
055 }
056
057 return false;
058 }
059
060 @Override
061 public int hashCode() {
062 return HashUtil.hash(0, licenseId);
063 }
064
065 @Override
066 public String toString() {
067 StringBundler sb = new StringBundler(15);
068
069 sb.append("{licenseId=");
070 sb.append(licenseId);
071 sb.append(", companyId=");
072 sb.append(companyId);
073 sb.append(", name=");
074 sb.append(name);
075 sb.append(", url=");
076 sb.append(url);
077 sb.append(", openSource=");
078 sb.append(openSource);
079 sb.append(", active=");
080 sb.append(active);
081 sb.append(", recommended=");
082 sb.append(recommended);
083 sb.append("}");
084
085 return sb.toString();
086 }
087
088 @Override
089 public SCLicense toEntityModel() {
090 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
091
092 scLicenseImpl.setLicenseId(licenseId);
093 scLicenseImpl.setCompanyId(companyId);
094
095 if (name == null) {
096 scLicenseImpl.setName(StringPool.BLANK);
097 }
098 else {
099 scLicenseImpl.setName(name);
100 }
101
102 if (url == null) {
103 scLicenseImpl.setUrl(StringPool.BLANK);
104 }
105 else {
106 scLicenseImpl.setUrl(url);
107 }
108
109 scLicenseImpl.setOpenSource(openSource);
110 scLicenseImpl.setActive(active);
111 scLicenseImpl.setRecommended(recommended);
112
113 scLicenseImpl.resetOriginalValues();
114
115 return scLicenseImpl;
116 }
117
118 @Override
119 public void readExternal(ObjectInput objectInput) throws IOException {
120 licenseId = objectInput.readLong();
121 companyId = objectInput.readLong();
122 name = objectInput.readUTF();
123 url = objectInput.readUTF();
124 openSource = objectInput.readBoolean();
125 active = objectInput.readBoolean();
126 recommended = objectInput.readBoolean();
127 }
128
129 @Override
130 public void writeExternal(ObjectOutput objectOutput)
131 throws IOException {
132 objectOutput.writeLong(licenseId);
133 objectOutput.writeLong(companyId);
134
135 if (name == null) {
136 objectOutput.writeUTF(StringPool.BLANK);
137 }
138 else {
139 objectOutput.writeUTF(name);
140 }
141
142 if (url == null) {
143 objectOutput.writeUTF(StringPool.BLANK);
144 }
145 else {
146 objectOutput.writeUTF(url);
147 }
148
149 objectOutput.writeBoolean(openSource);
150 objectOutput.writeBoolean(active);
151 objectOutput.writeBoolean(recommended);
152 }
153
154 public long licenseId;
155 public long companyId;
156 public String name;
157 public String url;
158 public boolean openSource;
159 public boolean active;
160 public boolean recommended;
161 }