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 * InventoryTransactionLineSourceValue.java
021 */
022
023package com.echothree.model.data.inventory.server.value;
024
025import com.echothree.model.data.inventory.common.pk.InventoryTransactionLineSourcePK;
026
027import com.echothree.model.data.inventory.server.factory.InventoryTransactionLineSourceFactory;
028
029import com.echothree.model.data.inventory.common.pk.InventoryTransactionLinePK;
030import com.echothree.model.data.party.common.pk.PartyPK;
031import com.echothree.model.data.warehouse.common.pk.LocationPK;
032import com.echothree.model.data.inventory.common.pk.InventoryConditionPK;
033import com.echothree.model.data.uom.common.pk.UnitOfMeasureTypePK;
034
035import com.echothree.util.common.exception.PersistenceCloneException;
036import com.echothree.util.common.exception.PersistenceNotNullException;
037
038import com.echothree.util.server.persistence.BaseValue;
039
040import java.io.Serializable;
041
042import javax.annotation.Nonnull;
043import javax.annotation.Nullable;
044
045public class InventoryTransactionLineSourceValue
046        extends BaseValue<InventoryTransactionLineSourcePK>
047        implements Cloneable, Serializable {
048    
049    private InventoryTransactionLinePK inventoryTransactionLinePK;
050    private boolean inventoryTransactionLinePKHasBeenModified = false;
051    private PartyPK sourceOwnerPartyPK;
052    private boolean sourceOwnerPartyPKHasBeenModified = false;
053    private LocationPK sourceLocationPK;
054    private boolean sourceLocationPKHasBeenModified = false;
055    private InventoryConditionPK sourceInventoryConditionPK;
056    private boolean sourceInventoryConditionPKHasBeenModified = false;
057    private UnitOfMeasureTypePK sourceUnitOfMeasureTypePK;
058    private boolean sourceUnitOfMeasureTypePKHasBeenModified = false;
059    private Long fromTime;
060    private boolean fromTimeHasBeenModified = false;
061    private Long thruTime;
062    private boolean thruTimeHasBeenModified = false;
063    
064    private transient Integer _hashCode = null;
065    private transient String _stringValue = null;
066    
067    private void constructFields(InventoryTransactionLinePK inventoryTransactionLinePK, PartyPK sourceOwnerPartyPK, LocationPK sourceLocationPK, InventoryConditionPK sourceInventoryConditionPK, UnitOfMeasureTypePK sourceUnitOfMeasureTypePK, Long fromTime, Long thruTime)
068            throws PersistenceNotNullException {
069        checkForNull(inventoryTransactionLinePK);
070        this.inventoryTransactionLinePK = inventoryTransactionLinePK;
071        this.sourceOwnerPartyPK = sourceOwnerPartyPK;
072        this.sourceLocationPK = sourceLocationPK;
073        this.sourceInventoryConditionPK = sourceInventoryConditionPK;
074        this.sourceUnitOfMeasureTypePK = sourceUnitOfMeasureTypePK;
075        checkForNull(fromTime);
076        this.fromTime = fromTime;
077        checkForNull(thruTime);
078        this.thruTime = thruTime;
079    }
080    
081    /** Creates a new instance of InventoryTransactionLineSourceValue */
082    public InventoryTransactionLineSourceValue(InventoryTransactionLineSourcePK inventoryTransactionLineSourcePK, InventoryTransactionLinePK inventoryTransactionLinePK, PartyPK sourceOwnerPartyPK, LocationPK sourceLocationPK, InventoryConditionPK sourceInventoryConditionPK, UnitOfMeasureTypePK sourceUnitOfMeasureTypePK, Long fromTime, Long thruTime)
083            throws PersistenceNotNullException {
084        super(inventoryTransactionLineSourcePK);
085        constructFields(inventoryTransactionLinePK, sourceOwnerPartyPK, sourceLocationPK, sourceInventoryConditionPK, sourceUnitOfMeasureTypePK, fromTime, thruTime);
086    }
087    
088    /** Creates a new instance of InventoryTransactionLineSourceValue */
089    public InventoryTransactionLineSourceValue(InventoryTransactionLinePK inventoryTransactionLinePK, PartyPK sourceOwnerPartyPK, LocationPK sourceLocationPK, InventoryConditionPK sourceInventoryConditionPK, UnitOfMeasureTypePK sourceUnitOfMeasureTypePK, Long fromTime, Long thruTime)
090            throws PersistenceNotNullException {
091        super();
092        constructFields(inventoryTransactionLinePK, sourceOwnerPartyPK, sourceLocationPK, sourceInventoryConditionPK, sourceUnitOfMeasureTypePK, fromTime, thruTime);
093    }
094    
095    @Override
096    @Nonnull
097    public InventoryTransactionLineSourceFactory getBaseFactoryInstance() {
098        return InventoryTransactionLineSourceFactory.getInstance();
099    }
100    
101    @Override
102    @Nonnull
103    public InventoryTransactionLineSourceValue clone() {
104        Object result;
105        
106        try {
107            result = super.clone();
108        } catch (CloneNotSupportedException cnse) {
109            // This shouldn't happen, fail when it does.
110            throw new PersistenceCloneException(cnse);
111        }
112        
113        return (InventoryTransactionLineSourceValue)result;
114    }
115    
116    @Override
117    @Nonnull
118    public InventoryTransactionLineSourcePK getPrimaryKey() {
119        if(_primaryKey == null) {
120            _primaryKey = new InventoryTransactionLineSourcePK(entityId);
121        }
122        
123        return _primaryKey;
124    }
125    
126    private void clearHashAndString() {
127        _hashCode = null;
128        _stringValue = null;
129    }
130    
131    @Override
132    public int hashCode() {
133        if(_hashCode == null) {
134            int hashCode = 17;
135            
136            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
137            
138            hashCode = 37 * hashCode + ((inventoryTransactionLinePK != null) ? inventoryTransactionLinePK.hashCode() : 0);
139            hashCode = 37 * hashCode + ((sourceOwnerPartyPK != null) ? sourceOwnerPartyPK.hashCode() : 0);
140            hashCode = 37 * hashCode + ((sourceLocationPK != null) ? sourceLocationPK.hashCode() : 0);
141            hashCode = 37 * hashCode + ((sourceInventoryConditionPK != null) ? sourceInventoryConditionPK.hashCode() : 0);
142            hashCode = 37 * hashCode + ((sourceUnitOfMeasureTypePK != null) ? sourceUnitOfMeasureTypePK.hashCode() : 0);
143            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
144            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
145            
146            _hashCode = hashCode;
147        }
148        
149        return _hashCode;
150    }
151    
152    @Override
153    @Nonnull
154    public String toString() {
155        if(_stringValue == null) {
156            _stringValue = "{" + 
157                    "entityId=" + getEntityId() +
158                    ", inventoryTransactionLinePK=" + getInventoryTransactionLinePK() +
159                    ", sourceOwnerPartyPK=" + getSourceOwnerPartyPK() +
160                    ", sourceLocationPK=" + getSourceLocationPK() +
161                    ", sourceInventoryConditionPK=" + getSourceInventoryConditionPK() +
162                    ", sourceUnitOfMeasureTypePK=" + getSourceUnitOfMeasureTypePK() +
163                    ", fromTime=" + getFromTime() +
164                    ", thruTime=" + getThruTime() +
165                    "}";
166        }
167        return _stringValue;
168    }
169    
170    @Override
171    public boolean equals(Object other) {
172        if(this == other)
173            return true;
174        
175        if(!hasIdentity())
176            return false;
177        
178        if(other instanceof  InventoryTransactionLineSourceValue that) {
179            if(!that.hasIdentity())
180                return false;
181            
182            Long thisEntityId = getEntityId();
183            Long thatEntityId = that.getEntityId();
184            
185            boolean objectsEqual = thisEntityId.equals(thatEntityId);
186            if(objectsEqual)
187                objectsEqual = isIdentical(that);
188            
189            return objectsEqual;
190        } else {
191            return false;
192        }
193    }
194    
195    public boolean isIdentical(Object other) {
196        if(other instanceof InventoryTransactionLineSourceValue that) {
197            boolean objectsEqual = true;
198            
199            
200            if(objectsEqual) {
201                InventoryTransactionLinePK thisInventoryTransactionLinePK = getInventoryTransactionLinePK();
202                InventoryTransactionLinePK thatInventoryTransactionLinePK = that.getInventoryTransactionLinePK();
203                
204                if(thisInventoryTransactionLinePK == null) {
205                    objectsEqual = objectsEqual && (thatInventoryTransactionLinePK == null);
206                } else {
207                    objectsEqual = objectsEqual && thisInventoryTransactionLinePK.equals(thatInventoryTransactionLinePK);
208                }
209            }
210            
211            if(objectsEqual) {
212                PartyPK thisSourceOwnerPartyPK = getSourceOwnerPartyPK();
213                PartyPK thatSourceOwnerPartyPK = that.getSourceOwnerPartyPK();
214                
215                if(thisSourceOwnerPartyPK == null) {
216                    objectsEqual = objectsEqual && (thatSourceOwnerPartyPK == null);
217                } else {
218                    objectsEqual = objectsEqual && thisSourceOwnerPartyPK.equals(thatSourceOwnerPartyPK);
219                }
220            }
221            
222            if(objectsEqual) {
223                LocationPK thisSourceLocationPK = getSourceLocationPK();
224                LocationPK thatSourceLocationPK = that.getSourceLocationPK();
225                
226                if(thisSourceLocationPK == null) {
227                    objectsEqual = objectsEqual && (thatSourceLocationPK == null);
228                } else {
229                    objectsEqual = objectsEqual && thisSourceLocationPK.equals(thatSourceLocationPK);
230                }
231            }
232            
233            if(objectsEqual) {
234                InventoryConditionPK thisSourceInventoryConditionPK = getSourceInventoryConditionPK();
235                InventoryConditionPK thatSourceInventoryConditionPK = that.getSourceInventoryConditionPK();
236                
237                if(thisSourceInventoryConditionPK == null) {
238                    objectsEqual = objectsEqual && (thatSourceInventoryConditionPK == null);
239                } else {
240                    objectsEqual = objectsEqual && thisSourceInventoryConditionPK.equals(thatSourceInventoryConditionPK);
241                }
242            }
243            
244            if(objectsEqual) {
245                UnitOfMeasureTypePK thisSourceUnitOfMeasureTypePK = getSourceUnitOfMeasureTypePK();
246                UnitOfMeasureTypePK thatSourceUnitOfMeasureTypePK = that.getSourceUnitOfMeasureTypePK();
247                
248                if(thisSourceUnitOfMeasureTypePK == null) {
249                    objectsEqual = objectsEqual && (thatSourceUnitOfMeasureTypePK == null);
250                } else {
251                    objectsEqual = objectsEqual && thisSourceUnitOfMeasureTypePK.equals(thatSourceUnitOfMeasureTypePK);
252                }
253            }
254            
255            if(objectsEqual) {
256                Long thisFromTime = getFromTime();
257                Long thatFromTime = that.getFromTime();
258                
259                if(thisFromTime == null) {
260                    objectsEqual = objectsEqual && (thatFromTime == null);
261                } else {
262                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
263                }
264            }
265            
266            if(objectsEqual) {
267                Long thisThruTime = getThruTime();
268                Long thatThruTime = that.getThruTime();
269                
270                if(thisThruTime == null) {
271                    objectsEqual = objectsEqual && (thatThruTime == null);
272                } else {
273                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
274                }
275            }
276            
277            return objectsEqual;
278        } else {
279            return false;
280        }
281    }
282    
283    @Override
284    public boolean hasBeenModified() {
285        return inventoryTransactionLinePKHasBeenModified || sourceOwnerPartyPKHasBeenModified || sourceLocationPKHasBeenModified || sourceInventoryConditionPKHasBeenModified || sourceUnitOfMeasureTypePKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
286    }
287    
288    @Override
289    public void clearHasBeenModified() {
290        inventoryTransactionLinePKHasBeenModified = false;
291        sourceOwnerPartyPKHasBeenModified = false;
292        sourceLocationPKHasBeenModified = false;
293        sourceInventoryConditionPKHasBeenModified = false;
294        sourceUnitOfMeasureTypePKHasBeenModified = false;
295        fromTimeHasBeenModified = false;
296        thruTimeHasBeenModified = false;
297    }
298    
299    @Nonnull
300    public InventoryTransactionLinePK getInventoryTransactionLinePK() {
301        return inventoryTransactionLinePK;
302    }
303    
304    public void setInventoryTransactionLinePK(@Nonnull InventoryTransactionLinePK inventoryTransactionLinePK)
305            throws PersistenceNotNullException {
306        checkForNull(inventoryTransactionLinePK);
307        
308        boolean update = true;
309        
310        if(this.inventoryTransactionLinePK != null) {
311            if(this.inventoryTransactionLinePK.equals(inventoryTransactionLinePK)) {
312                update = false;
313            }
314        } else if(inventoryTransactionLinePK == null) {
315            update = false;
316        }
317        
318        if(update) {
319            this.inventoryTransactionLinePK = inventoryTransactionLinePK;
320            inventoryTransactionLinePKHasBeenModified = true;
321            clearHashAndString();
322        }
323    }
324    
325    public boolean getInventoryTransactionLinePKHasBeenModified() {
326        return inventoryTransactionLinePKHasBeenModified;
327    }
328    
329    @Nullable
330    public PartyPK getSourceOwnerPartyPK() {
331        return sourceOwnerPartyPK;
332    }
333    
334    public void setSourceOwnerPartyPK(@Nullable PartyPK sourceOwnerPartyPK) {
335        boolean update = true;
336        
337        if(this.sourceOwnerPartyPK != null) {
338            if(this.sourceOwnerPartyPK.equals(sourceOwnerPartyPK)) {
339                update = false;
340            }
341        } else if(sourceOwnerPartyPK == null) {
342            update = false;
343        }
344        
345        if(update) {
346            this.sourceOwnerPartyPK = sourceOwnerPartyPK;
347            sourceOwnerPartyPKHasBeenModified = true;
348            clearHashAndString();
349        }
350    }
351    
352    public boolean getSourceOwnerPartyPKHasBeenModified() {
353        return sourceOwnerPartyPKHasBeenModified;
354    }
355    
356    @Nullable
357    public LocationPK getSourceLocationPK() {
358        return sourceLocationPK;
359    }
360    
361    public void setSourceLocationPK(@Nullable LocationPK sourceLocationPK) {
362        boolean update = true;
363        
364        if(this.sourceLocationPK != null) {
365            if(this.sourceLocationPK.equals(sourceLocationPK)) {
366                update = false;
367            }
368        } else if(sourceLocationPK == null) {
369            update = false;
370        }
371        
372        if(update) {
373            this.sourceLocationPK = sourceLocationPK;
374            sourceLocationPKHasBeenModified = true;
375            clearHashAndString();
376        }
377    }
378    
379    public boolean getSourceLocationPKHasBeenModified() {
380        return sourceLocationPKHasBeenModified;
381    }
382    
383    @Nullable
384    public InventoryConditionPK getSourceInventoryConditionPK() {
385        return sourceInventoryConditionPK;
386    }
387    
388    public void setSourceInventoryConditionPK(@Nullable InventoryConditionPK sourceInventoryConditionPK) {
389        boolean update = true;
390        
391        if(this.sourceInventoryConditionPK != null) {
392            if(this.sourceInventoryConditionPK.equals(sourceInventoryConditionPK)) {
393                update = false;
394            }
395        } else if(sourceInventoryConditionPK == null) {
396            update = false;
397        }
398        
399        if(update) {
400            this.sourceInventoryConditionPK = sourceInventoryConditionPK;
401            sourceInventoryConditionPKHasBeenModified = true;
402            clearHashAndString();
403        }
404    }
405    
406    public boolean getSourceInventoryConditionPKHasBeenModified() {
407        return sourceInventoryConditionPKHasBeenModified;
408    }
409    
410    @Nullable
411    public UnitOfMeasureTypePK getSourceUnitOfMeasureTypePK() {
412        return sourceUnitOfMeasureTypePK;
413    }
414    
415    public void setSourceUnitOfMeasureTypePK(@Nullable UnitOfMeasureTypePK sourceUnitOfMeasureTypePK) {
416        boolean update = true;
417        
418        if(this.sourceUnitOfMeasureTypePK != null) {
419            if(this.sourceUnitOfMeasureTypePK.equals(sourceUnitOfMeasureTypePK)) {
420                update = false;
421            }
422        } else if(sourceUnitOfMeasureTypePK == null) {
423            update = false;
424        }
425        
426        if(update) {
427            this.sourceUnitOfMeasureTypePK = sourceUnitOfMeasureTypePK;
428            sourceUnitOfMeasureTypePKHasBeenModified = true;
429            clearHashAndString();
430        }
431    }
432    
433    public boolean getSourceUnitOfMeasureTypePKHasBeenModified() {
434        return sourceUnitOfMeasureTypePKHasBeenModified;
435    }
436    
437    @Nonnull
438    public Long getFromTime() {
439        return fromTime;
440    }
441    
442    public void setFromTime(@Nonnull Long fromTime)
443            throws PersistenceNotNullException {
444        checkForNull(fromTime);
445        
446        boolean update = true;
447        
448        if(this.fromTime != null) {
449            if(this.fromTime.equals(fromTime)) {
450                update = false;
451            }
452        } else if(fromTime == null) {
453            update = false;
454        }
455        
456        if(update) {
457            this.fromTime = fromTime;
458            fromTimeHasBeenModified = true;
459            clearHashAndString();
460        }
461    }
462    
463    public boolean getFromTimeHasBeenModified() {
464        return fromTimeHasBeenModified;
465    }
466    
467    @Nonnull
468    public Long getThruTime() {
469        return thruTime;
470    }
471    
472    public void setThruTime(@Nonnull Long thruTime)
473            throws PersistenceNotNullException {
474        checkForNull(thruTime);
475        
476        boolean update = true;
477        
478        if(this.thruTime != null) {
479            if(this.thruTime.equals(thruTime)) {
480                update = false;
481            }
482        } else if(thruTime == null) {
483            update = false;
484        }
485        
486        if(update) {
487            this.thruTime = thruTime;
488            thruTimeHasBeenModified = true;
489            clearHashAndString();
490        }
491    }
492    
493    public boolean getThruTimeHasBeenModified() {
494        return thruTimeHasBeenModified;
495    }
496    
497}