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