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