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 * PartyInventoryCostingMethodValue.java
021 */
022
023package com.echothree.model.data.inventory.server.value;
024
025import com.echothree.model.data.inventory.common.pk.PartyInventoryCostingMethodPK;
026
027import com.echothree.model.data.inventory.server.factory.PartyInventoryCostingMethodFactory;
028
029import com.echothree.model.data.party.common.pk.LanguagePK;
030import com.echothree.model.data.inventory.common.pk.InventoryCostingMethodPK;
031
032import com.echothree.util.common.exception.PersistenceCloneException;
033import com.echothree.util.common.exception.PersistenceNotNullException;
034
035import com.echothree.util.server.persistence.BaseValue;
036
037import java.io.Serializable;
038
039import javax.annotation.Nonnull;
040import javax.annotation.Nullable;
041
042public class PartyInventoryCostingMethodValue
043        extends BaseValue<PartyInventoryCostingMethodPK>
044        implements Cloneable, Serializable {
045    
046    private LanguagePK partyPK;
047    private boolean partyPKHasBeenModified = false;
048    private InventoryCostingMethodPK inventoryCostingMethodPK;
049    private boolean inventoryCostingMethodPKHasBeenModified = false;
050    private Long fromTime;
051    private boolean fromTimeHasBeenModified = false;
052    private Long thruTime;
053    private boolean thruTimeHasBeenModified = false;
054    
055    private transient Integer _hashCode = null;
056    private transient String _stringValue = null;
057    
058    private void constructFields(LanguagePK partyPK, InventoryCostingMethodPK inventoryCostingMethodPK, Long fromTime, Long thruTime)
059            throws PersistenceNotNullException {
060        checkForNull(partyPK);
061        this.partyPK = partyPK;
062        checkForNull(inventoryCostingMethodPK);
063        this.inventoryCostingMethodPK = inventoryCostingMethodPK;
064        checkForNull(fromTime);
065        this.fromTime = fromTime;
066        checkForNull(thruTime);
067        this.thruTime = thruTime;
068    }
069    
070    /** Creates a new instance of PartyInventoryCostingMethodValue */
071    public PartyInventoryCostingMethodValue(PartyInventoryCostingMethodPK partyInventoryCostingMethodPK, LanguagePK partyPK, InventoryCostingMethodPK inventoryCostingMethodPK, Long fromTime, Long thruTime)
072            throws PersistenceNotNullException {
073        super(partyInventoryCostingMethodPK);
074        constructFields(partyPK, inventoryCostingMethodPK, fromTime, thruTime);
075    }
076    
077    /** Creates a new instance of PartyInventoryCostingMethodValue */
078    public PartyInventoryCostingMethodValue(LanguagePK partyPK, InventoryCostingMethodPK inventoryCostingMethodPK, Long fromTime, Long thruTime)
079            throws PersistenceNotNullException {
080        super();
081        constructFields(partyPK, inventoryCostingMethodPK, fromTime, thruTime);
082    }
083    
084    @Override
085    @Nonnull
086    public PartyInventoryCostingMethodFactory getBaseFactoryInstance() {
087        return PartyInventoryCostingMethodFactory.getInstance();
088    }
089    
090    @Override
091    @Nonnull
092    public PartyInventoryCostingMethodValue clone() {
093        Object result;
094        
095        try {
096            result = super.clone();
097        } catch (CloneNotSupportedException cnse) {
098            // This shouldn't happen, fail when it does.
099            throw new PersistenceCloneException(cnse);
100        }
101        
102        return (PartyInventoryCostingMethodValue)result;
103    }
104    
105    @Override
106    @Nonnull
107    public PartyInventoryCostingMethodPK getPrimaryKey() {
108        if(_primaryKey == null) {
109            _primaryKey = new PartyInventoryCostingMethodPK(entityId);
110        }
111        
112        return _primaryKey;
113    }
114    
115    private void clearHashAndString() {
116        _hashCode = null;
117        _stringValue = null;
118    }
119    
120    @Override
121    public int hashCode() {
122        if(_hashCode == null) {
123            int hashCode = 17;
124            
125            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
126            
127            hashCode = 37 * hashCode + ((partyPK != null) ? partyPK.hashCode() : 0);
128            hashCode = 37 * hashCode + ((inventoryCostingMethodPK != null) ? inventoryCostingMethodPK.hashCode() : 0);
129            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
130            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
131            
132            _hashCode = hashCode;
133        }
134        
135        return _hashCode;
136    }
137    
138    @Override
139    @Nonnull
140    public String toString() {
141        if(_stringValue == null) {
142            _stringValue = "{" + 
143                    "entityId=" + getEntityId() +
144                    ", partyPK=" + getPartyPK() +
145                    ", inventoryCostingMethodPK=" + getInventoryCostingMethodPK() +
146                    ", fromTime=" + getFromTime() +
147                    ", thruTime=" + getThruTime() +
148                    "}";
149        }
150        return _stringValue;
151    }
152    
153    @Override
154    public boolean equals(Object other) {
155        if(this == other)
156            return true;
157        
158        if(!hasIdentity())
159            return false;
160        
161        if(other instanceof  PartyInventoryCostingMethodValue that) {
162            if(!that.hasIdentity())
163                return false;
164            
165            Long thisEntityId = getEntityId();
166            Long thatEntityId = that.getEntityId();
167            
168            boolean objectsEqual = thisEntityId.equals(thatEntityId);
169            if(objectsEqual)
170                objectsEqual = isIdentical(that);
171            
172            return objectsEqual;
173        } else {
174            return false;
175        }
176    }
177    
178    public boolean isIdentical(Object other) {
179        if(other instanceof PartyInventoryCostingMethodValue that) {
180            boolean objectsEqual = true;
181            
182            
183            if(objectsEqual) {
184                LanguagePK thisPartyPK = getPartyPK();
185                LanguagePK thatPartyPK = that.getPartyPK();
186                
187                if(thisPartyPK == null) {
188                    objectsEqual = objectsEqual && (thatPartyPK == null);
189                } else {
190                    objectsEqual = objectsEqual && thisPartyPK.equals(thatPartyPK);
191                }
192            }
193            
194            if(objectsEqual) {
195                InventoryCostingMethodPK thisInventoryCostingMethodPK = getInventoryCostingMethodPK();
196                InventoryCostingMethodPK thatInventoryCostingMethodPK = that.getInventoryCostingMethodPK();
197                
198                if(thisInventoryCostingMethodPK == null) {
199                    objectsEqual = objectsEqual && (thatInventoryCostingMethodPK == null);
200                } else {
201                    objectsEqual = objectsEqual && thisInventoryCostingMethodPK.equals(thatInventoryCostingMethodPK);
202                }
203            }
204            
205            if(objectsEqual) {
206                Long thisFromTime = getFromTime();
207                Long thatFromTime = that.getFromTime();
208                
209                if(thisFromTime == null) {
210                    objectsEqual = objectsEqual && (thatFromTime == null);
211                } else {
212                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
213                }
214            }
215            
216            if(objectsEqual) {
217                Long thisThruTime = getThruTime();
218                Long thatThruTime = that.getThruTime();
219                
220                if(thisThruTime == null) {
221                    objectsEqual = objectsEqual && (thatThruTime == null);
222                } else {
223                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
224                }
225            }
226            
227            return objectsEqual;
228        } else {
229            return false;
230        }
231    }
232    
233    @Override
234    public boolean hasBeenModified() {
235        return partyPKHasBeenModified || inventoryCostingMethodPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
236    }
237    
238    @Override
239    public void clearHasBeenModified() {
240        partyPKHasBeenModified = false;
241        inventoryCostingMethodPKHasBeenModified = false;
242        fromTimeHasBeenModified = false;
243        thruTimeHasBeenModified = false;
244    }
245    
246    @Nonnull
247    public LanguagePK getPartyPK() {
248        return partyPK;
249    }
250    
251    public void setPartyPK(@Nonnull LanguagePK partyPK)
252            throws PersistenceNotNullException {
253        checkForNull(partyPK);
254        
255        boolean update = true;
256        
257        if(this.partyPK != null) {
258            if(this.partyPK.equals(partyPK)) {
259                update = false;
260            }
261        } else if(partyPK == null) {
262            update = false;
263        }
264        
265        if(update) {
266            this.partyPK = partyPK;
267            partyPKHasBeenModified = true;
268            clearHashAndString();
269        }
270    }
271    
272    public boolean getPartyPKHasBeenModified() {
273        return partyPKHasBeenModified;
274    }
275    
276    @Nonnull
277    public InventoryCostingMethodPK getInventoryCostingMethodPK() {
278        return inventoryCostingMethodPK;
279    }
280    
281    public void setInventoryCostingMethodPK(@Nonnull InventoryCostingMethodPK inventoryCostingMethodPK)
282            throws PersistenceNotNullException {
283        checkForNull(inventoryCostingMethodPK);
284        
285        boolean update = true;
286        
287        if(this.inventoryCostingMethodPK != null) {
288            if(this.inventoryCostingMethodPK.equals(inventoryCostingMethodPK)) {
289                update = false;
290            }
291        } else if(inventoryCostingMethodPK == null) {
292            update = false;
293        }
294        
295        if(update) {
296            this.inventoryCostingMethodPK = inventoryCostingMethodPK;
297            inventoryCostingMethodPKHasBeenModified = true;
298            clearHashAndString();
299        }
300    }
301    
302    public boolean getInventoryCostingMethodPKHasBeenModified() {
303        return inventoryCostingMethodPKHasBeenModified;
304    }
305    
306    @Nonnull
307    public Long getFromTime() {
308        return fromTime;
309    }
310    
311    public void setFromTime(@Nonnull Long fromTime)
312            throws PersistenceNotNullException {
313        checkForNull(fromTime);
314        
315        boolean update = true;
316        
317        if(this.fromTime != null) {
318            if(this.fromTime.equals(fromTime)) {
319                update = false;
320            }
321        } else if(fromTime == null) {
322            update = false;
323        }
324        
325        if(update) {
326            this.fromTime = fromTime;
327            fromTimeHasBeenModified = true;
328            clearHashAndString();
329        }
330    }
331    
332    public boolean getFromTimeHasBeenModified() {
333        return fromTimeHasBeenModified;
334    }
335    
336    @Nonnull
337    public Long getThruTime() {
338        return thruTime;
339    }
340    
341    public void setThruTime(@Nonnull Long thruTime)
342            throws PersistenceNotNullException {
343        checkForNull(thruTime);
344        
345        boolean update = true;
346        
347        if(this.thruTime != null) {
348            if(this.thruTime.equals(thruTime)) {
349                update = false;
350            }
351        } else if(thruTime == null) {
352            update = false;
353        }
354        
355        if(update) {
356            this.thruTime = thruTime;
357            thruTimeHasBeenModified = true;
358            clearHashAndString();
359        }
360    }
361    
362    public boolean getThruTimeHasBeenModified() {
363        return thruTimeHasBeenModified;
364    }
365    
366}