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