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 * InventoryTransactionTimeValue.java
021 */
022
023package com.echothree.model.data.inventory.server.value;
024
025import com.echothree.model.data.inventory.common.pk.InventoryTransactionTimePK;
026
027import com.echothree.model.data.inventory.server.factory.InventoryTransactionTimeFactory;
028
029import com.echothree.model.data.inventory.common.pk.InventoryTransactionPK;
030import com.echothree.model.data.inventory.common.pk.InventoryTransactionTimeTypePK;
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 InventoryTransactionTimeValue
043        extends BaseValue<InventoryTransactionTimePK>
044        implements Cloneable, Serializable {
045    
046    private InventoryTransactionPK inventoryTransactionPK;
047    private boolean inventoryTransactionPKHasBeenModified = false;
048    private InventoryTransactionTimeTypePK inventoryTransactionTimeTypePK;
049    private boolean inventoryTransactionTimeTypePKHasBeenModified = false;
050    private Long time;
051    private boolean timeHasBeenModified = false;
052    private Long fromTime;
053    private boolean fromTimeHasBeenModified = false;
054    private Long thruTime;
055    private boolean thruTimeHasBeenModified = false;
056    
057    private transient Integer _hashCode = null;
058    private transient String _stringValue = null;
059    
060    private void constructFields(InventoryTransactionPK inventoryTransactionPK, InventoryTransactionTimeTypePK inventoryTransactionTimeTypePK, Long time, Long fromTime, Long thruTime)
061            throws PersistenceNotNullException {
062        checkForNull(inventoryTransactionPK);
063        this.inventoryTransactionPK = inventoryTransactionPK;
064        checkForNull(inventoryTransactionTimeTypePK);
065        this.inventoryTransactionTimeTypePK = inventoryTransactionTimeTypePK;
066        checkForNull(time);
067        this.time = time;
068        checkForNull(fromTime);
069        this.fromTime = fromTime;
070        checkForNull(thruTime);
071        this.thruTime = thruTime;
072    }
073    
074    /** Creates a new instance of InventoryTransactionTimeValue */
075    public InventoryTransactionTimeValue(InventoryTransactionTimePK inventoryTransactionTimePK, InventoryTransactionPK inventoryTransactionPK, InventoryTransactionTimeTypePK inventoryTransactionTimeTypePK, Long time, Long fromTime, Long thruTime)
076            throws PersistenceNotNullException {
077        super(inventoryTransactionTimePK);
078        constructFields(inventoryTransactionPK, inventoryTransactionTimeTypePK, time, fromTime, thruTime);
079    }
080    
081    /** Creates a new instance of InventoryTransactionTimeValue */
082    public InventoryTransactionTimeValue(InventoryTransactionPK inventoryTransactionPK, InventoryTransactionTimeTypePK inventoryTransactionTimeTypePK, Long time, Long fromTime, Long thruTime)
083            throws PersistenceNotNullException {
084        super();
085        constructFields(inventoryTransactionPK, inventoryTransactionTimeTypePK, time, fromTime, thruTime);
086    }
087    
088    @Override
089    @Nonnull
090    public InventoryTransactionTimeFactory getBaseFactoryInstance() {
091        return InventoryTransactionTimeFactory.getInstance();
092    }
093    
094    @Override
095    @Nonnull
096    public InventoryTransactionTimeValue clone() {
097        Object result;
098        
099        try {
100            result = super.clone();
101        } catch (CloneNotSupportedException cnse) {
102            // This shouldn't happen, fail when it does.
103            throw new PersistenceCloneException(cnse);
104        }
105        
106        return (InventoryTransactionTimeValue)result;
107    }
108    
109    @Override
110    @Nonnull
111    public InventoryTransactionTimePK getPrimaryKey() {
112        if(_primaryKey == null) {
113            _primaryKey = new InventoryTransactionTimePK(entityId);
114        }
115        
116        return _primaryKey;
117    }
118    
119    private void clearHashAndString() {
120        _hashCode = null;
121        _stringValue = null;
122    }
123    
124    @Override
125    public int hashCode() {
126        if(_hashCode == null) {
127            int hashCode = 17;
128            
129            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
130            
131            hashCode = 37 * hashCode + ((inventoryTransactionPK != null) ? inventoryTransactionPK.hashCode() : 0);
132            hashCode = 37 * hashCode + ((inventoryTransactionTimeTypePK != null) ? inventoryTransactionTimeTypePK.hashCode() : 0);
133            hashCode = 37 * hashCode + ((time != null) ? time.hashCode() : 0);
134            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
135            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
136            
137            _hashCode = hashCode;
138        }
139        
140        return _hashCode;
141    }
142    
143    @Override
144    @Nonnull
145    public String toString() {
146        if(_stringValue == null) {
147            _stringValue = "{" + 
148                    "entityId=" + getEntityId() +
149                    ", inventoryTransactionPK=" + getInventoryTransactionPK() +
150                    ", inventoryTransactionTimeTypePK=" + getInventoryTransactionTimeTypePK() +
151                    ", time=" + getTime() +
152                    ", fromTime=" + getFromTime() +
153                    ", thruTime=" + getThruTime() +
154                    "}";
155        }
156        return _stringValue;
157    }
158    
159    @Override
160    public boolean equals(Object other) {
161        if(this == other)
162            return true;
163        
164        if(!hasIdentity())
165            return false;
166        
167        if(other instanceof  InventoryTransactionTimeValue that) {
168            if(!that.hasIdentity())
169                return false;
170            
171            Long thisEntityId = getEntityId();
172            Long thatEntityId = that.getEntityId();
173            
174            boolean objectsEqual = thisEntityId.equals(thatEntityId);
175            if(objectsEqual)
176                objectsEqual = isIdentical(that);
177            
178            return objectsEqual;
179        } else {
180            return false;
181        }
182    }
183    
184    public boolean isIdentical(Object other) {
185        if(other instanceof InventoryTransactionTimeValue that) {
186            boolean objectsEqual = true;
187            
188            
189            if(objectsEqual) {
190                InventoryTransactionPK thisInventoryTransactionPK = getInventoryTransactionPK();
191                InventoryTransactionPK thatInventoryTransactionPK = that.getInventoryTransactionPK();
192                
193                if(thisInventoryTransactionPK == null) {
194                    objectsEqual = objectsEqual && (thatInventoryTransactionPK == null);
195                } else {
196                    objectsEqual = objectsEqual && thisInventoryTransactionPK.equals(thatInventoryTransactionPK);
197                }
198            }
199            
200            if(objectsEqual) {
201                InventoryTransactionTimeTypePK thisInventoryTransactionTimeTypePK = getInventoryTransactionTimeTypePK();
202                InventoryTransactionTimeTypePK thatInventoryTransactionTimeTypePK = that.getInventoryTransactionTimeTypePK();
203                
204                if(thisInventoryTransactionTimeTypePK == null) {
205                    objectsEqual = objectsEqual && (thatInventoryTransactionTimeTypePK == null);
206                } else {
207                    objectsEqual = objectsEqual && thisInventoryTransactionTimeTypePK.equals(thatInventoryTransactionTimeTypePK);
208                }
209            }
210            
211            if(objectsEqual) {
212                Long thisTime = getTime();
213                Long thatTime = that.getTime();
214                
215                if(thisTime == null) {
216                    objectsEqual = objectsEqual && (thatTime == null);
217                } else {
218                    objectsEqual = objectsEqual && thisTime.equals(thatTime);
219                }
220            }
221            
222            if(objectsEqual) {
223                Long thisFromTime = getFromTime();
224                Long thatFromTime = that.getFromTime();
225                
226                if(thisFromTime == null) {
227                    objectsEqual = objectsEqual && (thatFromTime == null);
228                } else {
229                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
230                }
231            }
232            
233            if(objectsEqual) {
234                Long thisThruTime = getThruTime();
235                Long thatThruTime = that.getThruTime();
236                
237                if(thisThruTime == null) {
238                    objectsEqual = objectsEqual && (thatThruTime == null);
239                } else {
240                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
241                }
242            }
243            
244            return objectsEqual;
245        } else {
246            return false;
247        }
248    }
249    
250    @Override
251    public boolean hasBeenModified() {
252        return inventoryTransactionPKHasBeenModified || inventoryTransactionTimeTypePKHasBeenModified || timeHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
253    }
254    
255    @Override
256    public void clearHasBeenModified() {
257        inventoryTransactionPKHasBeenModified = false;
258        inventoryTransactionTimeTypePKHasBeenModified = false;
259        timeHasBeenModified = false;
260        fromTimeHasBeenModified = false;
261        thruTimeHasBeenModified = false;
262    }
263    
264    @Nonnull
265    public InventoryTransactionPK getInventoryTransactionPK() {
266        return inventoryTransactionPK;
267    }
268    
269    public void setInventoryTransactionPK(@Nonnull InventoryTransactionPK inventoryTransactionPK)
270            throws PersistenceNotNullException {
271        checkForNull(inventoryTransactionPK);
272        
273        boolean update = true;
274        
275        if(this.inventoryTransactionPK != null) {
276            if(this.inventoryTransactionPK.equals(inventoryTransactionPK)) {
277                update = false;
278            }
279        } else if(inventoryTransactionPK == null) {
280            update = false;
281        }
282        
283        if(update) {
284            this.inventoryTransactionPK = inventoryTransactionPK;
285            inventoryTransactionPKHasBeenModified = true;
286            clearHashAndString();
287        }
288    }
289    
290    public boolean getInventoryTransactionPKHasBeenModified() {
291        return inventoryTransactionPKHasBeenModified;
292    }
293    
294    @Nonnull
295    public InventoryTransactionTimeTypePK getInventoryTransactionTimeTypePK() {
296        return inventoryTransactionTimeTypePK;
297    }
298    
299    public void setInventoryTransactionTimeTypePK(@Nonnull InventoryTransactionTimeTypePK inventoryTransactionTimeTypePK)
300            throws PersistenceNotNullException {
301        checkForNull(inventoryTransactionTimeTypePK);
302        
303        boolean update = true;
304        
305        if(this.inventoryTransactionTimeTypePK != null) {
306            if(this.inventoryTransactionTimeTypePK.equals(inventoryTransactionTimeTypePK)) {
307                update = false;
308            }
309        } else if(inventoryTransactionTimeTypePK == null) {
310            update = false;
311        }
312        
313        if(update) {
314            this.inventoryTransactionTimeTypePK = inventoryTransactionTimeTypePK;
315            inventoryTransactionTimeTypePKHasBeenModified = true;
316            clearHashAndString();
317        }
318    }
319    
320    public boolean getInventoryTransactionTimeTypePKHasBeenModified() {
321        return inventoryTransactionTimeTypePKHasBeenModified;
322    }
323    
324    @Nonnull
325    public Long getTime() {
326        return time;
327    }
328    
329    public void setTime(@Nonnull Long time)
330            throws PersistenceNotNullException {
331        checkForNull(time);
332        
333        boolean update = true;
334        
335        if(this.time != null) {
336            if(this.time.equals(time)) {
337                update = false;
338            }
339        } else if(time == null) {
340            update = false;
341        }
342        
343        if(update) {
344            this.time = time;
345            timeHasBeenModified = true;
346            clearHashAndString();
347        }
348    }
349    
350    public boolean getTimeHasBeenModified() {
351        return timeHasBeenModified;
352    }
353    
354    @Nonnull
355    public Long getFromTime() {
356        return fromTime;
357    }
358    
359    public void setFromTime(@Nonnull Long fromTime)
360            throws PersistenceNotNullException {
361        checkForNull(fromTime);
362        
363        boolean update = true;
364        
365        if(this.fromTime != null) {
366            if(this.fromTime.equals(fromTime)) {
367                update = false;
368            }
369        } else if(fromTime == null) {
370            update = false;
371        }
372        
373        if(update) {
374            this.fromTime = fromTime;
375            fromTimeHasBeenModified = true;
376            clearHashAndString();
377        }
378    }
379    
380    public boolean getFromTimeHasBeenModified() {
381        return fromTimeHasBeenModified;
382    }
383    
384    @Nonnull
385    public Long getThruTime() {
386        return thruTime;
387    }
388    
389    public void setThruTime(@Nonnull Long thruTime)
390            throws PersistenceNotNullException {
391        checkForNull(thruTime);
392        
393        boolean update = true;
394        
395        if(this.thruTime != null) {
396            if(this.thruTime.equals(thruTime)) {
397                update = false;
398            }
399        } else if(thruTime == null) {
400            update = false;
401        }
402        
403        if(update) {
404            this.thruTime = thruTime;
405            thruTimeHasBeenModified = true;
406            clearHashAndString();
407        }
408    }
409    
410    public boolean getThruTimeHasBeenModified() {
411        return thruTimeHasBeenModified;
412    }
413    
414}