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 * IndexStatusValue.java 021 */ 022 023package com.echothree.model.data.index.server.value; 024 025import com.echothree.model.data.index.common.pk.IndexStatusPK; 026 027import com.echothree.model.data.index.server.factory.IndexStatusFactory; 028 029import com.echothree.model.data.index.common.pk.IndexPK; 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 IndexStatusValue 042 extends BaseValue<IndexStatusPK> 043 implements Cloneable, Serializable { 044 045 private IndexPK indexPK; 046 private boolean indexPKHasBeenModified = false; 047 private Long createdTime; 048 private boolean createdTimeHasBeenModified = false; 049 050 private transient Integer _hashCode = null; 051 private transient String _stringValue = null; 052 053 private void constructFields(IndexPK indexPK, Long createdTime) 054 throws PersistenceNotNullException { 055 checkForNull(indexPK); 056 this.indexPK = indexPK; 057 this.createdTime = createdTime; 058 } 059 060 /** Creates a new instance of IndexStatusValue */ 061 public IndexStatusValue(IndexStatusPK indexStatusPK, IndexPK indexPK, Long createdTime) 062 throws PersistenceNotNullException { 063 super(indexStatusPK); 064 constructFields(indexPK, createdTime); 065 } 066 067 /** Creates a new instance of IndexStatusValue */ 068 public IndexStatusValue(IndexPK indexPK, Long createdTime) 069 throws PersistenceNotNullException { 070 super(); 071 constructFields(indexPK, createdTime); 072 } 073 074 @Override 075 @Nonnull 076 public IndexStatusFactory getBaseFactoryInstance() { 077 return IndexStatusFactory.getInstance(); 078 } 079 080 @Override 081 @Nonnull 082 public IndexStatusValue clone() { 083 Object result; 084 085 try { 086 result = super.clone(); 087 } catch (CloneNotSupportedException cnse) { 088 // This shouldn't happen, fail when it does. 089 throw new PersistenceCloneException(cnse); 090 } 091 092 return (IndexStatusValue)result; 093 } 094 095 @Override 096 @Nonnull 097 public IndexStatusPK getPrimaryKey() { 098 if(_primaryKey == null) { 099 _primaryKey = new IndexStatusPK(entityId); 100 } 101 102 return _primaryKey; 103 } 104 105 private void clearHashAndString() { 106 _hashCode = null; 107 _stringValue = null; 108 } 109 110 @Override 111 public int hashCode() { 112 if(_hashCode == null) { 113 int hashCode = 17; 114 115 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 116 117 hashCode = 37 * hashCode + ((indexPK != null) ? indexPK.hashCode() : 0); 118 hashCode = 37 * hashCode + ((createdTime != null) ? createdTime.hashCode() : 0); 119 120 _hashCode = hashCode; 121 } 122 123 return _hashCode; 124 } 125 126 @Override 127 @Nonnull 128 public String toString() { 129 if(_stringValue == null) { 130 _stringValue = "{" + 131 "entityId=" + getEntityId() + 132 ", indexPK=" + getIndexPK() + 133 ", createdTime=" + getCreatedTime() + 134 "}"; 135 } 136 return _stringValue; 137 } 138 139 @Override 140 public boolean equals(Object other) { 141 if(this == other) 142 return true; 143 144 if(!hasIdentity()) 145 return false; 146 147 if(other instanceof IndexStatusValue that) { 148 if(!that.hasIdentity()) 149 return false; 150 151 Long thisEntityId = getEntityId(); 152 Long thatEntityId = that.getEntityId(); 153 154 boolean objectsEqual = thisEntityId.equals(thatEntityId); 155 if(objectsEqual) 156 objectsEqual = isIdentical(that); 157 158 return objectsEqual; 159 } else { 160 return false; 161 } 162 } 163 164 public boolean isIdentical(Object other) { 165 if(other instanceof IndexStatusValue that) { 166 boolean objectsEqual = true; 167 168 169 if(objectsEqual) { 170 IndexPK thisIndexPK = getIndexPK(); 171 IndexPK thatIndexPK = that.getIndexPK(); 172 173 if(thisIndexPK == null) { 174 objectsEqual = objectsEqual && (thatIndexPK == null); 175 } else { 176 objectsEqual = objectsEqual && thisIndexPK.equals(thatIndexPK); 177 } 178 } 179 180 if(objectsEqual) { 181 Long thisCreatedTime = getCreatedTime(); 182 Long thatCreatedTime = that.getCreatedTime(); 183 184 if(thisCreatedTime == null) { 185 objectsEqual = objectsEqual && (thatCreatedTime == null); 186 } else { 187 objectsEqual = objectsEqual && thisCreatedTime.equals(thatCreatedTime); 188 } 189 } 190 191 return objectsEqual; 192 } else { 193 return false; 194 } 195 } 196 197 @Override 198 public boolean hasBeenModified() { 199 return indexPKHasBeenModified || createdTimeHasBeenModified; 200 } 201 202 @Override 203 public void clearHasBeenModified() { 204 indexPKHasBeenModified = false; 205 createdTimeHasBeenModified = false; 206 } 207 208 @Nonnull 209 public IndexPK getIndexPK() { 210 return indexPK; 211 } 212 213 public void setIndexPK(@Nonnull IndexPK indexPK) 214 throws PersistenceNotNullException { 215 checkForNull(indexPK); 216 217 boolean update = true; 218 219 if(this.indexPK != null) { 220 if(this.indexPK.equals(indexPK)) { 221 update = false; 222 } 223 } else if(indexPK == null) { 224 update = false; 225 } 226 227 if(update) { 228 this.indexPK = indexPK; 229 indexPKHasBeenModified = true; 230 clearHashAndString(); 231 } 232 } 233 234 public boolean getIndexPKHasBeenModified() { 235 return indexPKHasBeenModified; 236 } 237 238 @Nullable 239 public Long getCreatedTime() { 240 return createdTime; 241 } 242 243 public void setCreatedTime(@Nullable Long createdTime) { 244 boolean update = true; 245 246 if(this.createdTime != null) { 247 if(this.createdTime.equals(createdTime)) { 248 update = false; 249 } 250 } else if(createdTime == null) { 251 update = false; 252 } 253 254 if(update) { 255 this.createdTime = createdTime; 256 createdTimeHasBeenModified = true; 257 clearHashAndString(); 258 } 259 } 260 261 public boolean getCreatedTimeHasBeenModified() { 262 return createdTimeHasBeenModified; 263 } 264 265}