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 * JobStatusValue.java 021 */ 022 023package com.echothree.model.data.job.server.value; 024 025import com.echothree.model.data.job.common.pk.JobStatusPK; 026 027import com.echothree.model.data.job.server.factory.JobStatusFactory; 028 029import com.echothree.model.data.job.common.pk.JobPK; 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 javax.annotation.Nonnull; 039import javax.annotation.Nullable; 040 041public class JobStatusValue 042 extends BaseValue<JobStatusPK> 043 implements Cloneable, Serializable { 044 045 private JobPK jobPK; 046 private boolean jobPKHasBeenModified = false; 047 private Long lastStartTime; 048 private boolean lastStartTimeHasBeenModified = false; 049 private Long lastEndTime; 050 private boolean lastEndTimeHasBeenModified = false; 051 052 private transient Integer _hashCode = null; 053 private transient String _stringValue = null; 054 055 private void constructFields(JobPK jobPK, Long lastStartTime, Long lastEndTime) 056 throws PersistenceNotNullException { 057 checkForNull(jobPK); 058 this.jobPK = jobPK; 059 this.lastStartTime = lastStartTime; 060 this.lastEndTime = lastEndTime; 061 } 062 063 /** Creates a new instance of JobStatusValue */ 064 public JobStatusValue(JobStatusPK jobStatusPK, JobPK jobPK, Long lastStartTime, Long lastEndTime) 065 throws PersistenceNotNullException { 066 super(jobStatusPK); 067 constructFields(jobPK, lastStartTime, lastEndTime); 068 } 069 070 /** Creates a new instance of JobStatusValue */ 071 public JobStatusValue(JobPK jobPK, Long lastStartTime, Long lastEndTime) 072 throws PersistenceNotNullException { 073 super(); 074 constructFields(jobPK, lastStartTime, lastEndTime); 075 } 076 077 @Override 078 @Nonnull 079 public JobStatusFactory getBaseFactoryInstance() { 080 return JobStatusFactory.getInstance(); 081 } 082 083 @Override 084 @Nonnull 085 public JobStatusValue clone() { 086 Object result; 087 088 try { 089 result = super.clone(); 090 } catch (CloneNotSupportedException cnse) { 091 // This shouldn't happen, fail when it does. 092 throw new PersistenceCloneException(cnse); 093 } 094 095 return (JobStatusValue)result; 096 } 097 098 @Override 099 @Nonnull 100 public JobStatusPK getPrimaryKey() { 101 if(_primaryKey == null) { 102 _primaryKey = new JobStatusPK(entityId); 103 } 104 105 return _primaryKey; 106 } 107 108 private void clearHashAndString() { 109 _hashCode = null; 110 _stringValue = null; 111 } 112 113 @Override 114 public int hashCode() { 115 if(_hashCode == null) { 116 int hashCode = 17; 117 118 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 119 120 hashCode = 37 * hashCode + ((jobPK != null) ? jobPK.hashCode() : 0); 121 hashCode = 37 * hashCode + ((lastStartTime != null) ? lastStartTime.hashCode() : 0); 122 hashCode = 37 * hashCode + ((lastEndTime != null) ? lastEndTime.hashCode() : 0); 123 124 _hashCode = hashCode; 125 } 126 127 return _hashCode; 128 } 129 130 @Override 131 @Nonnull 132 public String toString() { 133 if(_stringValue == null) { 134 _stringValue = "{" + 135 "entityId=" + getEntityId() + 136 ", jobPK=" + getJobPK() + 137 ", lastStartTime=" + getLastStartTime() + 138 ", lastEndTime=" + getLastEndTime() + 139 "}"; 140 } 141 return _stringValue; 142 } 143 144 @Override 145 public boolean equals(Object other) { 146 if(this == other) 147 return true; 148 149 if(!hasIdentity()) 150 return false; 151 152 if(other instanceof JobStatusValue that) { 153 if(!that.hasIdentity()) 154 return false; 155 156 Long thisEntityId = getEntityId(); 157 Long thatEntityId = that.getEntityId(); 158 159 boolean objectsEqual = thisEntityId.equals(thatEntityId); 160 if(objectsEqual) 161 objectsEqual = isIdentical(that); 162 163 return objectsEqual; 164 } else { 165 return false; 166 } 167 } 168 169 public boolean isIdentical(Object other) { 170 if(other instanceof JobStatusValue that) { 171 boolean objectsEqual = true; 172 173 174 if(objectsEqual) { 175 JobPK thisJobPK = getJobPK(); 176 JobPK thatJobPK = that.getJobPK(); 177 178 if(thisJobPK == null) { 179 objectsEqual = objectsEqual && (thatJobPK == null); 180 } else { 181 objectsEqual = objectsEqual && thisJobPK.equals(thatJobPK); 182 } 183 } 184 185 if(objectsEqual) { 186 Long thisLastStartTime = getLastStartTime(); 187 Long thatLastStartTime = that.getLastStartTime(); 188 189 if(thisLastStartTime == null) { 190 objectsEqual = objectsEqual && (thatLastStartTime == null); 191 } else { 192 objectsEqual = objectsEqual && thisLastStartTime.equals(thatLastStartTime); 193 } 194 } 195 196 if(objectsEqual) { 197 Long thisLastEndTime = getLastEndTime(); 198 Long thatLastEndTime = that.getLastEndTime(); 199 200 if(thisLastEndTime == null) { 201 objectsEqual = objectsEqual && (thatLastEndTime == null); 202 } else { 203 objectsEqual = objectsEqual && thisLastEndTime.equals(thatLastEndTime); 204 } 205 } 206 207 return objectsEqual; 208 } else { 209 return false; 210 } 211 } 212 213 @Override 214 public boolean hasBeenModified() { 215 return jobPKHasBeenModified || lastStartTimeHasBeenModified || lastEndTimeHasBeenModified; 216 } 217 218 @Override 219 public void clearHasBeenModified() { 220 jobPKHasBeenModified = false; 221 lastStartTimeHasBeenModified = false; 222 lastEndTimeHasBeenModified = false; 223 } 224 225 @Nonnull 226 public JobPK getJobPK() { 227 return jobPK; 228 } 229 230 public void setJobPK(@Nonnull JobPK jobPK) 231 throws PersistenceNotNullException { 232 checkForNull(jobPK); 233 234 boolean update = true; 235 236 if(this.jobPK != null) { 237 if(this.jobPK.equals(jobPK)) { 238 update = false; 239 } 240 } else if(jobPK == null) { 241 update = false; 242 } 243 244 if(update) { 245 this.jobPK = jobPK; 246 jobPKHasBeenModified = true; 247 clearHashAndString(); 248 } 249 } 250 251 public boolean getJobPKHasBeenModified() { 252 return jobPKHasBeenModified; 253 } 254 255 @Nullable 256 public Long getLastStartTime() { 257 return lastStartTime; 258 } 259 260 public void setLastStartTime(@Nullable Long lastStartTime) { 261 boolean update = true; 262 263 if(this.lastStartTime != null) { 264 if(this.lastStartTime.equals(lastStartTime)) { 265 update = false; 266 } 267 } else if(lastStartTime == null) { 268 update = false; 269 } 270 271 if(update) { 272 this.lastStartTime = lastStartTime; 273 lastStartTimeHasBeenModified = true; 274 clearHashAndString(); 275 } 276 } 277 278 public boolean getLastStartTimeHasBeenModified() { 279 return lastStartTimeHasBeenModified; 280 } 281 282 @Nullable 283 public Long getLastEndTime() { 284 return lastEndTime; 285 } 286 287 public void setLastEndTime(@Nullable Long lastEndTime) { 288 boolean update = true; 289 290 if(this.lastEndTime != null) { 291 if(this.lastEndTime.equals(lastEndTime)) { 292 update = false; 293 } 294 } else if(lastEndTime == null) { 295 update = false; 296 } 297 298 if(update) { 299 this.lastEndTime = lastEndTime; 300 lastEndTimeHasBeenModified = true; 301 clearHashAndString(); 302 } 303 } 304 305 public boolean getLastEndTimeHasBeenModified() { 306 return lastEndTimeHasBeenModified; 307 } 308 309}