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