001// -------------------------------------------------------------------------------- 002// Copyright 2002-2025 Echo Three, LLC 003// 004// Licensed under the Apache License, Version 2.0 (the "License"); 005// you may not use this file except in compliance with the License. 006// You may obtain a copy of the License at 007// 008// http://www.apache.org/licenses/LICENSE-2.0 009// 010// Unless required by applicable law or agreed to in writing, software 011// distributed under the License is distributed on an "AS IS" BASIS, 012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013// See the License for the specific language governing permissions and 014// limitations under the License. 015// -------------------------------------------------------------------------------- 016// Generated File -- DO NOT EDIT BY HAND 017// -------------------------------------------------------------------------------- 018 019/** 020 * ForumBlobMessagePartValue.java 021 */ 022 023package com.echothree.model.data.forum.server.value; 024 025import com.echothree.model.data.forum.common.pk.ForumBlobMessagePartPK; 026 027import com.echothree.model.data.forum.server.factory.ForumBlobMessagePartFactory; 028 029import com.echothree.model.data.forum.common.pk.ForumMessagePartPK; 030 031import com.echothree.util.common.exception.PersistenceCloneException; 032import com.echothree.util.common.exception.PersistenceNotNullException; 033 034import com.echothree.util.server.persistence.BaseValue; 035 036import java.io.Serializable; 037 038import com.echothree.util.common.persistence.type.ByteArray; 039 040public class ForumBlobMessagePartValue 041 extends BaseValue<ForumBlobMessagePartPK> 042 implements Cloneable, Serializable { 043 044 private ForumMessagePartPK forumMessagePartPK; 045 private boolean forumMessagePartPKHasBeenModified = false; 046 private ByteArray blob; 047 private boolean blobHasBeenModified = false; 048 private Long fromTime; 049 private boolean fromTimeHasBeenModified = false; 050 private Long thruTime; 051 private boolean thruTimeHasBeenModified = false; 052 053 private transient Integer _hashCode = null; 054 private transient String _stringValue = null; 055 056 private void constructFields(ForumMessagePartPK forumMessagePartPK, ByteArray blob, Long fromTime, Long thruTime) 057 throws PersistenceNotNullException { 058 checkForNull(forumMessagePartPK); 059 this.forumMessagePartPK = forumMessagePartPK; 060 checkForNull(blob); 061 this.blob = blob; 062 checkForNull(fromTime); 063 this.fromTime = fromTime; 064 checkForNull(thruTime); 065 this.thruTime = thruTime; 066 } 067 068 /** Creates a new instance of ForumBlobMessagePartValue */ 069 public ForumBlobMessagePartValue(ForumBlobMessagePartPK forumBlobMessagePartPK, ForumMessagePartPK forumMessagePartPK, ByteArray blob, Long fromTime, Long thruTime) 070 throws PersistenceNotNullException { 071 super(forumBlobMessagePartPK); 072 constructFields(forumMessagePartPK, blob, fromTime, thruTime); 073 } 074 075 /** Creates a new instance of ForumBlobMessagePartValue */ 076 public ForumBlobMessagePartValue(ForumMessagePartPK forumMessagePartPK, ByteArray blob, Long fromTime, Long thruTime) 077 throws PersistenceNotNullException { 078 super(); 079 constructFields(forumMessagePartPK, blob, fromTime, thruTime); 080 } 081 082 @Override 083 public ForumBlobMessagePartFactory getBaseFactoryInstance() { 084 return ForumBlobMessagePartFactory.getInstance(); 085 } 086 087 @Override 088 public ForumBlobMessagePartValue clone() { 089 Object result; 090 091 try { 092 result = super.clone(); 093 } catch (CloneNotSupportedException cnse) { 094 // This shouldn't happen, fail when it does. 095 throw new PersistenceCloneException(cnse); 096 } 097 098 return (ForumBlobMessagePartValue)result; 099 } 100 101 @Override 102 public ForumBlobMessagePartPK getPrimaryKey() { 103 if(_primaryKey == null) { 104 _primaryKey = new ForumBlobMessagePartPK(entityId); 105 } 106 107 return _primaryKey; 108 } 109 110 private void clearHashAndString() { 111 _hashCode = null; 112 _stringValue = null; 113 } 114 115 @Override 116 public int hashCode() { 117 if(_hashCode == null) { 118 int hashCode = 17; 119 120 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 121 122 hashCode = 37 * hashCode + ((forumMessagePartPK != null) ? forumMessagePartPK.hashCode() : 0); 123 hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0); 124 hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0); 125 126 _hashCode = hashCode; 127 } 128 129 return _hashCode; 130 } 131 132 @Override 133 public String toString() { 134 if(_stringValue == null) { 135 _stringValue = "{" + 136 "entityId=" + getEntityId() + 137 ", forumMessagePartPK=" + getForumMessagePartPK() + 138 ", fromTime=" + getFromTime() + 139 ", thruTime=" + getThruTime() + 140 "}"; 141 } 142 return _stringValue; 143 } 144 145 @Override 146 public boolean equals(Object other) { 147 if(this == other) 148 return true; 149 150 if(!hasIdentity()) 151 return false; 152 153 if(other instanceof ForumBlobMessagePartValue that) { 154 if(!that.hasIdentity()) 155 return false; 156 157 Long thisEntityId = getEntityId(); 158 Long thatEntityId = that.getEntityId(); 159 160 boolean objectsEqual = thisEntityId.equals(thatEntityId); 161 if(objectsEqual) 162 objectsEqual = isIdentical(that); 163 164 return objectsEqual; 165 } else { 166 return false; 167 } 168 } 169 170 public boolean isIdentical(Object other) { 171 if(other instanceof ForumBlobMessagePartValue that) { 172 boolean objectsEqual = true; 173 174 175 if(objectsEqual) { 176 ForumMessagePartPK thisForumMessagePartPK = getForumMessagePartPK(); 177 ForumMessagePartPK thatForumMessagePartPK = that.getForumMessagePartPK(); 178 179 if(thisForumMessagePartPK == null) { 180 objectsEqual = objectsEqual && (thatForumMessagePartPK == null); 181 } else { 182 objectsEqual = objectsEqual && thisForumMessagePartPK.equals(thatForumMessagePartPK); 183 } 184 } 185 186 if(objectsEqual) { 187 ByteArray thisBlob = getBlob(); 188 ByteArray thatBlob = that.getBlob(); 189 190 if(thisBlob == null) { 191 objectsEqual = objectsEqual && (thatBlob == null); 192 } else { 193 objectsEqual = objectsEqual && thisBlob.equals(thatBlob); 194 } 195 } 196 197 if(objectsEqual) { 198 Long thisFromTime = getFromTime(); 199 Long thatFromTime = that.getFromTime(); 200 201 if(thisFromTime == null) { 202 objectsEqual = objectsEqual && (thatFromTime == null); 203 } else { 204 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 205 } 206 } 207 208 if(objectsEqual) { 209 Long thisThruTime = getThruTime(); 210 Long thatThruTime = that.getThruTime(); 211 212 if(thisThruTime == null) { 213 objectsEqual = objectsEqual && (thatThruTime == null); 214 } else { 215 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 216 } 217 } 218 219 return objectsEqual; 220 } else { 221 return false; 222 } 223 } 224 225 @Override 226 public boolean hasBeenModified() { 227 return forumMessagePartPKHasBeenModified || blobHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 228 } 229 230 @Override 231 public void clearHasBeenModified() { 232 forumMessagePartPKHasBeenModified = false; 233 blobHasBeenModified = false; 234 fromTimeHasBeenModified = false; 235 thruTimeHasBeenModified = false; 236 } 237 238 public ForumMessagePartPK getForumMessagePartPK() { 239 return forumMessagePartPK; 240 } 241 242 public void setForumMessagePartPK(ForumMessagePartPK forumMessagePartPK) 243 throws PersistenceNotNullException { 244 checkForNull(forumMessagePartPK); 245 246 boolean update = true; 247 248 if(this.forumMessagePartPK != null) { 249 if(this.forumMessagePartPK.equals(forumMessagePartPK)) { 250 update = false; 251 } 252 } else if(forumMessagePartPK == null) { 253 update = false; 254 } 255 256 if(update) { 257 this.forumMessagePartPK = forumMessagePartPK; 258 forumMessagePartPKHasBeenModified = true; 259 clearHashAndString(); 260 } 261 } 262 263 public boolean getForumMessagePartPKHasBeenModified() { 264 return forumMessagePartPKHasBeenModified; 265 } 266 267 public ByteArray getBlob() { 268 return blob; 269 } 270 271 public void setBlob(ByteArray blob) 272 throws PersistenceNotNullException { 273 checkForNull(blob); 274 275 boolean update = true; 276 277 if(this.blob != null) { 278 if(this.blob.equals(blob)) { 279 update = false; 280 } 281 } else if(blob == null) { 282 update = false; 283 } 284 285 if(update) { 286 this.blob = blob; 287 blobHasBeenModified = true; 288 clearHashAndString(); 289 } 290 } 291 292 public boolean getBlobHasBeenModified() { 293 return blobHasBeenModified; 294 } 295 296 public Long getFromTime() { 297 return fromTime; 298 } 299 300 public void setFromTime(Long fromTime) 301 throws PersistenceNotNullException { 302 checkForNull(fromTime); 303 304 boolean update = true; 305 306 if(this.fromTime != null) { 307 if(this.fromTime.equals(fromTime)) { 308 update = false; 309 } 310 } else if(fromTime == null) { 311 update = false; 312 } 313 314 if(update) { 315 this.fromTime = fromTime; 316 fromTimeHasBeenModified = true; 317 clearHashAndString(); 318 } 319 } 320 321 public boolean getFromTimeHasBeenModified() { 322 return fromTimeHasBeenModified; 323 } 324 325 public Long getThruTime() { 326 return thruTime; 327 } 328 329 public void setThruTime(Long thruTime) 330 throws PersistenceNotNullException { 331 checkForNull(thruTime); 332 333 boolean update = true; 334 335 if(this.thruTime != null) { 336 if(this.thruTime.equals(thruTime)) { 337 update = false; 338 } 339 } else if(thruTime == null) { 340 update = false; 341 } 342 343 if(update) { 344 this.thruTime = thruTime; 345 thruTimeHasBeenModified = true; 346 clearHashAndString(); 347 } 348 } 349 350 public boolean getThruTimeHasBeenModified() { 351 return thruTimeHasBeenModified; 352 } 353 354}