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