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