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 * InventoryDispositionAdjustmentValue.java 021 */ 022 023package com.echothree.model.data.inventory.server.value; 024 025import com.echothree.model.data.inventory.common.pk.InventoryDispositionAdjustmentPK; 026 027import com.echothree.model.data.inventory.server.factory.InventoryDispositionAdjustmentFactory; 028 029import com.echothree.model.data.inventory.common.pk.InventoryDispositionAdjustmentDetailPK; 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 InventoryDispositionAdjustmentValue 042 extends BaseValue<InventoryDispositionAdjustmentPK> 043 implements Cloneable, Serializable { 044 045 private InventoryDispositionAdjustmentDetailPK activeDetailPK; 046 private boolean activeDetailPKHasBeenModified = false; 047 private InventoryDispositionAdjustmentDetailPK lastDetailPK; 048 private boolean lastDetailPKHasBeenModified = false; 049 050 private transient Integer _hashCode = null; 051 private transient String _stringValue = null; 052 053 private void constructFields(InventoryDispositionAdjustmentDetailPK activeDetailPK, InventoryDispositionAdjustmentDetailPK lastDetailPK) 054 throws PersistenceNotNullException { 055 this.activeDetailPK = activeDetailPK; 056 this.lastDetailPK = lastDetailPK; 057 } 058 059 /** Creates a new instance of InventoryDispositionAdjustmentValue */ 060 public InventoryDispositionAdjustmentValue(InventoryDispositionAdjustmentPK inventoryDispositionAdjustmentPK, InventoryDispositionAdjustmentDetailPK activeDetailPK, InventoryDispositionAdjustmentDetailPK lastDetailPK) 061 throws PersistenceNotNullException { 062 super(inventoryDispositionAdjustmentPK); 063 constructFields(activeDetailPK, lastDetailPK); 064 } 065 066 /** Creates a new instance of InventoryDispositionAdjustmentValue */ 067 public InventoryDispositionAdjustmentValue(InventoryDispositionAdjustmentDetailPK activeDetailPK, InventoryDispositionAdjustmentDetailPK lastDetailPK) 068 throws PersistenceNotNullException { 069 super(); 070 constructFields(activeDetailPK, lastDetailPK); 071 } 072 073 @Override 074 @Nonnull 075 public InventoryDispositionAdjustmentFactory getBaseFactoryInstance() { 076 return InventoryDispositionAdjustmentFactory.getInstance(); 077 } 078 079 @Override 080 @Nonnull 081 public InventoryDispositionAdjustmentValue 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 (InventoryDispositionAdjustmentValue)result; 092 } 093 094 @Override 095 @Nonnull 096 public InventoryDispositionAdjustmentPK getPrimaryKey() { 097 if(_primaryKey == null) { 098 _primaryKey = new InventoryDispositionAdjustmentPK(entityId); 099 } 100 101 return _primaryKey; 102 } 103 104 private void clearHashAndString() { 105 _hashCode = null; 106 _stringValue = null; 107 } 108 109 @Override 110 public int hashCode() { 111 if(_hashCode == null) { 112 int hashCode = 17; 113 114 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 115 116 hashCode = 37 * hashCode + ((activeDetailPK != null) ? activeDetailPK.hashCode() : 0); 117 hashCode = 37 * hashCode + ((lastDetailPK != null) ? lastDetailPK.hashCode() : 0); 118 119 _hashCode = hashCode; 120 } 121 122 return _hashCode; 123 } 124 125 @Override 126 @Nonnull 127 public String toString() { 128 if(_stringValue == null) { 129 _stringValue = "{" + 130 "entityId=" + getEntityId() + 131 ", activeDetailPK=" + getActiveDetailPK() + 132 ", lastDetailPK=" + getLastDetailPK() + 133 "}"; 134 } 135 return _stringValue; 136 } 137 138 @Override 139 public boolean equals(Object other) { 140 if(this == other) 141 return true; 142 143 if(!hasIdentity()) 144 return false; 145 146 if(other instanceof InventoryDispositionAdjustmentValue that) { 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 = isIdentical(that); 156 157 return objectsEqual; 158 } else { 159 return false; 160 } 161 } 162 163 public boolean isIdentical(Object other) { 164 if(other instanceof InventoryDispositionAdjustmentValue that) { 165 boolean objectsEqual = true; 166 167 168 if(objectsEqual) { 169 InventoryDispositionAdjustmentDetailPK thisActiveDetailPK = getActiveDetailPK(); 170 InventoryDispositionAdjustmentDetailPK thatActiveDetailPK = that.getActiveDetailPK(); 171 172 if(thisActiveDetailPK == null) { 173 objectsEqual = objectsEqual && (thatActiveDetailPK == null); 174 } else { 175 objectsEqual = objectsEqual && thisActiveDetailPK.equals(thatActiveDetailPK); 176 } 177 } 178 179 if(objectsEqual) { 180 InventoryDispositionAdjustmentDetailPK thisLastDetailPK = getLastDetailPK(); 181 InventoryDispositionAdjustmentDetailPK thatLastDetailPK = that.getLastDetailPK(); 182 183 if(thisLastDetailPK == null) { 184 objectsEqual = objectsEqual && (thatLastDetailPK == null); 185 } else { 186 objectsEqual = objectsEqual && thisLastDetailPK.equals(thatLastDetailPK); 187 } 188 } 189 190 return objectsEqual; 191 } else { 192 return false; 193 } 194 } 195 196 @Override 197 public boolean hasBeenModified() { 198 return activeDetailPKHasBeenModified || lastDetailPKHasBeenModified; 199 } 200 201 @Override 202 public void clearHasBeenModified() { 203 activeDetailPKHasBeenModified = false; 204 lastDetailPKHasBeenModified = false; 205 } 206 207 @Nullable 208 public InventoryDispositionAdjustmentDetailPK getActiveDetailPK() { 209 return activeDetailPK; 210 } 211 212 public void setActiveDetailPK(@Nullable InventoryDispositionAdjustmentDetailPK 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 @Nullable 235 public InventoryDispositionAdjustmentDetailPK getLastDetailPK() { 236 return lastDetailPK; 237 } 238 239 public void setLastDetailPK(@Nullable InventoryDispositionAdjustmentDetailPK lastDetailPK) { 240 boolean update = true; 241 242 if(this.lastDetailPK != null) { 243 if(this.lastDetailPK.equals(lastDetailPK)) { 244 update = false; 245 } 246 } else if(lastDetailPK == null) { 247 update = false; 248 } 249 250 if(update) { 251 this.lastDetailPK = lastDetailPK; 252 lastDetailPKHasBeenModified = true; 253 clearHashAndString(); 254 } 255 } 256 257 public boolean getLastDetailPKHasBeenModified() { 258 return lastDetailPKHasBeenModified; 259 } 260 261}