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