001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 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 * QueuedEntityValue.java 021 */ 022 023package com.echothree.model.data.queue.server.value; 024 025import com.echothree.model.data.queue.common.pk.QueuedEntityPK; 026 027import com.echothree.model.data.queue.server.factory.QueuedEntityFactory; 028 029import com.echothree.model.data.queue.common.pk.QueueTypePK; 030import com.echothree.model.data.core.common.pk.EntityInstancePK; 031 032import com.echothree.util.common.exception.PersistenceCloneException; 033import com.echothree.util.common.exception.PersistenceNotNullException; 034 035import com.echothree.util.server.persistence.BaseValue; 036 037import java.io.Serializable; 038 039import javax.annotation.Nonnull; 040import javax.annotation.Nullable; 041 042public class QueuedEntityValue 043 extends BaseValue<QueuedEntityPK> 044 implements Cloneable, Serializable { 045 046 private QueueTypePK queueTypePK; 047 private boolean queueTypePKHasBeenModified = false; 048 private EntityInstancePK entityInstancePK; 049 private boolean entityInstancePKHasBeenModified = false; 050 private Long time; 051 private boolean timeHasBeenModified = false; 052 053 private transient Integer _hashCode = null; 054 private transient String _stringValue = null; 055 056 private void constructFields(QueueTypePK queueTypePK, EntityInstancePK entityInstancePK, Long time) 057 throws PersistenceNotNullException { 058 checkForNull(queueTypePK); 059 this.queueTypePK = queueTypePK; 060 checkForNull(entityInstancePK); 061 this.entityInstancePK = entityInstancePK; 062 checkForNull(time); 063 this.time = time; 064 } 065 066 /** Creates a new instance of QueuedEntityValue */ 067 public QueuedEntityValue(QueuedEntityPK queuedEntityPK, QueueTypePK queueTypePK, EntityInstancePK entityInstancePK, Long time) 068 throws PersistenceNotNullException { 069 super(queuedEntityPK); 070 constructFields(queueTypePK, entityInstancePK, time); 071 } 072 073 /** Creates a new instance of QueuedEntityValue */ 074 public QueuedEntityValue(QueueTypePK queueTypePK, EntityInstancePK entityInstancePK, Long time) 075 throws PersistenceNotNullException { 076 super(); 077 constructFields(queueTypePK, entityInstancePK, time); 078 } 079 080 @Override 081 @Nonnull 082 public QueuedEntityFactory getBaseFactoryInstance() { 083 return QueuedEntityFactory.getInstance(); 084 } 085 086 @Override 087 @Nonnull 088 public QueuedEntityValue 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 (QueuedEntityValue)result; 099 } 100 101 @Override 102 @Nonnull 103 public QueuedEntityPK getPrimaryKey() { 104 if(_primaryKey == null) { 105 _primaryKey = new QueuedEntityPK(entityId); 106 } 107 108 return _primaryKey; 109 } 110 111 private void clearHashAndString() { 112 _hashCode = null; 113 _stringValue = null; 114 } 115 116 @Override 117 public int hashCode() { 118 if(_hashCode == null) { 119 int hashCode = 17; 120 121 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 122 123 hashCode = 37 * hashCode + ((queueTypePK != null) ? queueTypePK.hashCode() : 0); 124 hashCode = 37 * hashCode + ((entityInstancePK != null) ? entityInstancePK.hashCode() : 0); 125 hashCode = 37 * hashCode + ((time != null) ? time.hashCode() : 0); 126 127 _hashCode = hashCode; 128 } 129 130 return _hashCode; 131 } 132 133 @Override 134 @Nonnull 135 public String toString() { 136 if(_stringValue == null) { 137 _stringValue = "{" + 138 "entityId=" + getEntityId() + 139 ", queueTypePK=" + getQueueTypePK() + 140 ", entityInstancePK=" + getEntityInstancePK() + 141 ", time=" + getTime() + 142 "}"; 143 } 144 return _stringValue; 145 } 146 147 @Override 148 public boolean equals(Object other) { 149 if(this == other) 150 return true; 151 152 if(!hasIdentity()) 153 return false; 154 155 if(other instanceof QueuedEntityValue that) { 156 if(!that.hasIdentity()) 157 return false; 158 159 Long thisEntityId = getEntityId(); 160 Long thatEntityId = that.getEntityId(); 161 162 boolean objectsEqual = thisEntityId.equals(thatEntityId); 163 if(objectsEqual) 164 objectsEqual = isIdentical(that); 165 166 return objectsEqual; 167 } else { 168 return false; 169 } 170 } 171 172 public boolean isIdentical(Object other) { 173 if(other instanceof QueuedEntityValue that) { 174 boolean objectsEqual = true; 175 176 177 if(objectsEqual) { 178 QueueTypePK thisQueueTypePK = getQueueTypePK(); 179 QueueTypePK thatQueueTypePK = that.getQueueTypePK(); 180 181 if(thisQueueTypePK == null) { 182 objectsEqual = objectsEqual && (thatQueueTypePK == null); 183 } else { 184 objectsEqual = objectsEqual && thisQueueTypePK.equals(thatQueueTypePK); 185 } 186 } 187 188 if(objectsEqual) { 189 EntityInstancePK thisEntityInstancePK = getEntityInstancePK(); 190 EntityInstancePK thatEntityInstancePK = that.getEntityInstancePK(); 191 192 if(thisEntityInstancePK == null) { 193 objectsEqual = objectsEqual && (thatEntityInstancePK == null); 194 } else { 195 objectsEqual = objectsEqual && thisEntityInstancePK.equals(thatEntityInstancePK); 196 } 197 } 198 199 if(objectsEqual) { 200 Long thisTime = getTime(); 201 Long thatTime = that.getTime(); 202 203 if(thisTime == null) { 204 objectsEqual = objectsEqual && (thatTime == null); 205 } else { 206 objectsEqual = objectsEqual && thisTime.equals(thatTime); 207 } 208 } 209 210 return objectsEqual; 211 } else { 212 return false; 213 } 214 } 215 216 @Override 217 public boolean hasBeenModified() { 218 return queueTypePKHasBeenModified || entityInstancePKHasBeenModified || timeHasBeenModified; 219 } 220 221 @Override 222 public void clearHasBeenModified() { 223 queueTypePKHasBeenModified = false; 224 entityInstancePKHasBeenModified = false; 225 timeHasBeenModified = false; 226 } 227 228 @Nonnull 229 public QueueTypePK getQueueTypePK() { 230 return queueTypePK; 231 } 232 233 public void setQueueTypePK(@Nonnull QueueTypePK queueTypePK) 234 throws PersistenceNotNullException { 235 checkForNull(queueTypePK); 236 237 boolean update = true; 238 239 if(this.queueTypePK != null) { 240 if(this.queueTypePK.equals(queueTypePK)) { 241 update = false; 242 } 243 } else if(queueTypePK == null) { 244 update = false; 245 } 246 247 if(update) { 248 this.queueTypePK = queueTypePK; 249 queueTypePKHasBeenModified = true; 250 clearHashAndString(); 251 } 252 } 253 254 public boolean getQueueTypePKHasBeenModified() { 255 return queueTypePKHasBeenModified; 256 } 257 258 @Nonnull 259 public EntityInstancePK getEntityInstancePK() { 260 return entityInstancePK; 261 } 262 263 public void setEntityInstancePK(@Nonnull EntityInstancePK entityInstancePK) 264 throws PersistenceNotNullException { 265 checkForNull(entityInstancePK); 266 267 boolean update = true; 268 269 if(this.entityInstancePK != null) { 270 if(this.entityInstancePK.equals(entityInstancePK)) { 271 update = false; 272 } 273 } else if(entityInstancePK == null) { 274 update = false; 275 } 276 277 if(update) { 278 this.entityInstancePK = entityInstancePK; 279 entityInstancePKHasBeenModified = true; 280 clearHashAndString(); 281 } 282 } 283 284 public boolean getEntityInstancePKHasBeenModified() { 285 return entityInstancePKHasBeenModified; 286 } 287 288 @Nonnull 289 public Long getTime() { 290 return time; 291 } 292 293 public void setTime(@Nonnull Long time) 294 throws PersistenceNotNullException { 295 checkForNull(time); 296 297 boolean update = true; 298 299 if(this.time != null) { 300 if(this.time.equals(time)) { 301 update = false; 302 } 303 } else if(time == null) { 304 update = false; 305 } 306 307 if(update) { 308 this.time = time; 309 timeHasBeenModified = true; 310 clearHashAndString(); 311 } 312 } 313 314 public boolean getTimeHasBeenModified() { 315 return timeHasBeenModified; 316 } 317 318}