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