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 * Customer.java
021 */
022
023package com.echothree.model.data.customer.server.entity;
024
025import com.echothree.model.data.customer.common.pk.CustomerPK;
026
027import com.echothree.model.data.party.common.pk.PartyPK;
028import com.echothree.model.data.customer.common.pk.CustomerTypePK;
029import com.echothree.model.data.offer.common.pk.OfferUsePK;
030import com.echothree.model.data.cancellationpolicy.common.pk.CancellationPolicyPK;
031import com.echothree.model.data.returnpolicy.common.pk.ReturnPolicyPK;
032import com.echothree.model.data.accounting.common.pk.GlAccountPK;
033
034import com.echothree.model.data.party.server.entity.Party;
035import com.echothree.model.data.customer.server.entity.CustomerType;
036import com.echothree.model.data.offer.server.entity.OfferUse;
037import com.echothree.model.data.cancellationpolicy.server.entity.CancellationPolicy;
038import com.echothree.model.data.returnpolicy.server.entity.ReturnPolicy;
039import com.echothree.model.data.accounting.server.entity.GlAccount;
040
041import com.echothree.model.data.party.server.factory.PartyFactory;
042import com.echothree.model.data.customer.server.factory.CustomerTypeFactory;
043import com.echothree.model.data.offer.server.factory.OfferUseFactory;
044import com.echothree.model.data.cancellationpolicy.server.factory.CancellationPolicyFactory;
045import com.echothree.model.data.returnpolicy.server.factory.ReturnPolicyFactory;
046import com.echothree.model.data.accounting.server.factory.GlAccountFactory;
047
048import com.echothree.model.data.customer.common.pk.CustomerPK;
049
050import com.echothree.model.data.customer.server.value.CustomerValue;
051
052import com.echothree.model.data.customer.server.factory.CustomerFactory;
053
054import com.echothree.util.common.exception.PersistenceException;
055import com.echothree.util.common.exception.PersistenceDatabaseException;
056import com.echothree.util.common.exception.PersistenceNotNullException;
057import com.echothree.util.common.exception.PersistenceReadOnlyException;
058
059import com.echothree.util.common.persistence.BasePK;
060
061import com.echothree.util.common.persistence.type.ByteArray;
062
063import com.echothree.util.server.persistence.BaseEntity;
064import com.echothree.util.server.persistence.EntityPermission;
065import com.echothree.util.server.persistence.Session;
066import com.echothree.util.server.persistence.ThreadSession;
067
068import java.io.Serializable;
069
070import javax.annotation.Nonnull;
071import javax.annotation.Nullable;
072
073public class Customer
074        extends BaseEntity
075        implements Serializable {
076    
077    private CustomerPK _pk;
078    private CustomerValue _value;
079    
080    /** Creates a new instance of Customer */
081    public Customer()
082            throws PersistenceException {
083        super();
084    }
085    
086    /** Creates a new instance of Customer */
087    public Customer(CustomerValue value, EntityPermission entityPermission) {
088        super(entityPermission);
089        
090        _value = value;
091        _pk = value.getPrimaryKey();
092    }
093    
094    @Override
095    @Nonnull
096    public CustomerFactory getBaseFactoryInstance() {
097        return CustomerFactory.getInstance();
098    }
099    
100    @Override
101    public boolean hasBeenModified() {
102        return _value.hasBeenModified();
103    }
104    
105    @Override
106    public int hashCode() {
107        return _pk.hashCode();
108    }
109    
110    @Override
111    @Nonnull
112    public String toString() {
113        return _pk.toString();
114    }
115    
116    @Override
117    public boolean equals(Object other) {
118        if(this == other)
119            return true;
120        
121        if(other instanceof Customer that) {
122            CustomerValue thatValue = that.getCustomerValue();
123            return _value.equals(thatValue);
124        } else {
125            return false;
126        }
127    }
128    
129    @Override
130    public void store()
131            throws PersistenceDatabaseException {
132        getBaseFactoryInstance().store(this);
133    }
134    
135    @Override
136    public void remove()
137            throws PersistenceDatabaseException {
138        getBaseFactoryInstance().remove(this);
139    }
140    
141    @Nonnull
142    public CustomerValue getCustomerValue() {
143        return _value;
144    }
145    
146    public void setCustomerValue(@Nonnull CustomerValue value)
147            throws PersistenceReadOnlyException {
148        checkReadWrite();
149        _value = value;
150    }
151    
152    @Override
153    @Nonnull
154    public CustomerPK getPrimaryKey() {
155        return _pk;
156    }
157    
158    @Nonnull
159    public PartyPK getPartyPK() {
160        return _value.getPartyPK();
161    }
162    
163    @Nonnull
164    public Party getParty(EntityPermission entityPermission) {
165        return PartyFactory.getInstance().getEntityFromPK(entityPermission, getPartyPK());
166    }
167    
168    @Nonnull
169    public Party getParty() {
170        return getParty(EntityPermission.READ_ONLY);
171    }
172    
173    @Nonnull
174    public Party getPartyForUpdate() {
175        return getParty(EntityPermission.READ_WRITE);
176    }
177    
178    public void setPartyPK(@Nonnull PartyPK partyPK)
179            throws PersistenceNotNullException, PersistenceReadOnlyException {
180        checkReadWrite();
181        _value.setPartyPK(partyPK);
182    }
183    
184    public void setParty(@Nonnull Party entity) {
185        setPartyPK(entity == null ? null : entity.getPrimaryKey());
186    }
187    
188    public boolean getPartyPKHasBeenModified() {
189        return _value.getPartyPKHasBeenModified();
190    }
191    
192    @Nonnull
193    public String getCustomerName() {
194        return _value.getCustomerName();
195    }
196    
197    public void setCustomerName(@Nonnull String customerName)
198            throws PersistenceNotNullException, PersistenceReadOnlyException {
199        checkReadWrite();
200        _value.setCustomerName(customerName);
201    }
202    
203    public boolean getCustomerNameHasBeenModified() {
204        return _value.getCustomerNameHasBeenModified();
205    }
206    
207    @Nonnull
208    public CustomerTypePK getCustomerTypePK() {
209        return _value.getCustomerTypePK();
210    }
211    
212    @Nonnull
213    public CustomerType getCustomerType(EntityPermission entityPermission) {
214        return CustomerTypeFactory.getInstance().getEntityFromPK(entityPermission, getCustomerTypePK());
215    }
216    
217    @Nonnull
218    public CustomerType getCustomerType() {
219        return getCustomerType(EntityPermission.READ_ONLY);
220    }
221    
222    @Nonnull
223    public CustomerType getCustomerTypeForUpdate() {
224        return getCustomerType(EntityPermission.READ_WRITE);
225    }
226    
227    public void setCustomerTypePK(@Nonnull CustomerTypePK customerTypePK)
228            throws PersistenceNotNullException, PersistenceReadOnlyException {
229        checkReadWrite();
230        _value.setCustomerTypePK(customerTypePK);
231    }
232    
233    public void setCustomerType(@Nonnull CustomerType entity) {
234        setCustomerTypePK(entity == null ? null : entity.getPrimaryKey());
235    }
236    
237    public boolean getCustomerTypePKHasBeenModified() {
238        return _value.getCustomerTypePKHasBeenModified();
239    }
240    
241    @Nonnull
242    public OfferUsePK getInitialOfferUsePK() {
243        return _value.getInitialOfferUsePK();
244    }
245    
246    @Nonnull
247    public OfferUse getInitialOfferUse(EntityPermission entityPermission) {
248        return OfferUseFactory.getInstance().getEntityFromPK(entityPermission, getInitialOfferUsePK());
249    }
250    
251    @Nonnull
252    public OfferUse getInitialOfferUse() {
253        return getInitialOfferUse(EntityPermission.READ_ONLY);
254    }
255    
256    @Nonnull
257    public OfferUse getInitialOfferUseForUpdate() {
258        return getInitialOfferUse(EntityPermission.READ_WRITE);
259    }
260    
261    public void setInitialOfferUsePK(@Nonnull OfferUsePK initialOfferUsePK)
262            throws PersistenceNotNullException, PersistenceReadOnlyException {
263        checkReadWrite();
264        _value.setInitialOfferUsePK(initialOfferUsePK);
265    }
266    
267    public void setInitialOfferUse(@Nonnull OfferUse entity) {
268        setInitialOfferUsePK(entity == null ? null : entity.getPrimaryKey());
269    }
270    
271    public boolean getInitialOfferUsePKHasBeenModified() {
272        return _value.getInitialOfferUsePKHasBeenModified();
273    }
274    
275    @Nullable
276    public CancellationPolicyPK getCancellationPolicyPK() {
277        return _value.getCancellationPolicyPK();
278    }
279    
280    @Nullable
281    public CancellationPolicy getCancellationPolicy(EntityPermission entityPermission) {
282        CancellationPolicyPK pk = getCancellationPolicyPK();
283        CancellationPolicy entity = pk == null? null: CancellationPolicyFactory.getInstance().getEntityFromPK(entityPermission, pk);
284        
285        return entity;
286    }
287    
288    @Nullable
289    public CancellationPolicy getCancellationPolicy() {
290        return getCancellationPolicy(EntityPermission.READ_ONLY);
291    }
292    
293    @Nullable
294    public CancellationPolicy getCancellationPolicyForUpdate() {
295        return getCancellationPolicy(EntityPermission.READ_WRITE);
296    }
297    
298    public void setCancellationPolicyPK(@Nullable CancellationPolicyPK cancellationPolicyPK)
299            throws PersistenceNotNullException, PersistenceReadOnlyException {
300        checkReadWrite();
301        _value.setCancellationPolicyPK(cancellationPolicyPK);
302    }
303    
304    public void setCancellationPolicy(@Nullable CancellationPolicy entity) {
305        setCancellationPolicyPK(entity == null ? null : entity.getPrimaryKey());
306    }
307    
308    public boolean getCancellationPolicyPKHasBeenModified() {
309        return _value.getCancellationPolicyPKHasBeenModified();
310    }
311    
312    @Nullable
313    public ReturnPolicyPK getReturnPolicyPK() {
314        return _value.getReturnPolicyPK();
315    }
316    
317    @Nullable
318    public ReturnPolicy getReturnPolicy(EntityPermission entityPermission) {
319        ReturnPolicyPK pk = getReturnPolicyPK();
320        ReturnPolicy entity = pk == null? null: ReturnPolicyFactory.getInstance().getEntityFromPK(entityPermission, pk);
321        
322        return entity;
323    }
324    
325    @Nullable
326    public ReturnPolicy getReturnPolicy() {
327        return getReturnPolicy(EntityPermission.READ_ONLY);
328    }
329    
330    @Nullable
331    public ReturnPolicy getReturnPolicyForUpdate() {
332        return getReturnPolicy(EntityPermission.READ_WRITE);
333    }
334    
335    public void setReturnPolicyPK(@Nullable ReturnPolicyPK returnPolicyPK)
336            throws PersistenceNotNullException, PersistenceReadOnlyException {
337        checkReadWrite();
338        _value.setReturnPolicyPK(returnPolicyPK);
339    }
340    
341    public void setReturnPolicy(@Nullable ReturnPolicy entity) {
342        setReturnPolicyPK(entity == null ? null : entity.getPrimaryKey());
343    }
344    
345    public boolean getReturnPolicyPKHasBeenModified() {
346        return _value.getReturnPolicyPKHasBeenModified();
347    }
348    
349    @Nullable
350    public GlAccountPK getArGlAccountPK() {
351        return _value.getArGlAccountPK();
352    }
353    
354    @Nullable
355    public GlAccount getArGlAccount(EntityPermission entityPermission) {
356        GlAccountPK pk = getArGlAccountPK();
357        GlAccount entity = pk == null? null: GlAccountFactory.getInstance().getEntityFromPK(entityPermission, pk);
358        
359        return entity;
360    }
361    
362    @Nullable
363    public GlAccount getArGlAccount() {
364        return getArGlAccount(EntityPermission.READ_ONLY);
365    }
366    
367    @Nullable
368    public GlAccount getArGlAccountForUpdate() {
369        return getArGlAccount(EntityPermission.READ_WRITE);
370    }
371    
372    public void setArGlAccountPK(@Nullable GlAccountPK arGlAccountPK)
373            throws PersistenceNotNullException, PersistenceReadOnlyException {
374        checkReadWrite();
375        _value.setArGlAccountPK(arGlAccountPK);
376    }
377    
378    public void setArGlAccount(@Nullable GlAccount entity) {
379        setArGlAccountPK(entity == null ? null : entity.getPrimaryKey());
380    }
381    
382    public boolean getArGlAccountPKHasBeenModified() {
383        return _value.getArGlAccountPKHasBeenModified();
384    }
385    
386    @Nonnull
387    public Boolean getHoldUntilComplete() {
388        return _value.getHoldUntilComplete();
389    }
390    
391    public void setHoldUntilComplete(@Nonnull Boolean holdUntilComplete)
392            throws PersistenceNotNullException, PersistenceReadOnlyException {
393        checkReadWrite();
394        _value.setHoldUntilComplete(holdUntilComplete);
395    }
396    
397    public boolean getHoldUntilCompleteHasBeenModified() {
398        return _value.getHoldUntilCompleteHasBeenModified();
399    }
400    
401    @Nonnull
402    public Boolean getAllowBackorders() {
403        return _value.getAllowBackorders();
404    }
405    
406    public void setAllowBackorders(@Nonnull Boolean allowBackorders)
407            throws PersistenceNotNullException, PersistenceReadOnlyException {
408        checkReadWrite();
409        _value.setAllowBackorders(allowBackorders);
410    }
411    
412    public boolean getAllowBackordersHasBeenModified() {
413        return _value.getAllowBackordersHasBeenModified();
414    }
415    
416    @Nonnull
417    public Boolean getAllowSubstitutions() {
418        return _value.getAllowSubstitutions();
419    }
420    
421    public void setAllowSubstitutions(@Nonnull Boolean allowSubstitutions)
422            throws PersistenceNotNullException, PersistenceReadOnlyException {
423        checkReadWrite();
424        _value.setAllowSubstitutions(allowSubstitutions);
425    }
426    
427    public boolean getAllowSubstitutionsHasBeenModified() {
428        return _value.getAllowSubstitutionsHasBeenModified();
429    }
430    
431    @Nonnull
432    public Boolean getAllowCombiningShipments() {
433        return _value.getAllowCombiningShipments();
434    }
435    
436    public void setAllowCombiningShipments(@Nonnull Boolean allowCombiningShipments)
437            throws PersistenceNotNullException, PersistenceReadOnlyException {
438        checkReadWrite();
439        _value.setAllowCombiningShipments(allowCombiningShipments);
440    }
441    
442    public boolean getAllowCombiningShipmentsHasBeenModified() {
443        return _value.getAllowCombiningShipmentsHasBeenModified();
444    }
445    
446    @Nonnull
447    public Boolean getRequireReference() {
448        return _value.getRequireReference();
449    }
450    
451    public void setRequireReference(@Nonnull Boolean requireReference)
452            throws PersistenceNotNullException, PersistenceReadOnlyException {
453        checkReadWrite();
454        _value.setRequireReference(requireReference);
455    }
456    
457    public boolean getRequireReferenceHasBeenModified() {
458        return _value.getRequireReferenceHasBeenModified();
459    }
460    
461    @Nonnull
462    public Boolean getAllowReferenceDuplicates() {
463        return _value.getAllowReferenceDuplicates();
464    }
465    
466    public void setAllowReferenceDuplicates(@Nonnull Boolean allowReferenceDuplicates)
467            throws PersistenceNotNullException, PersistenceReadOnlyException {
468        checkReadWrite();
469        _value.setAllowReferenceDuplicates(allowReferenceDuplicates);
470    }
471    
472    public boolean getAllowReferenceDuplicatesHasBeenModified() {
473        return _value.getAllowReferenceDuplicatesHasBeenModified();
474    }
475    
476    @Nullable
477    public String getReferenceValidationPattern() {
478        return _value.getReferenceValidationPattern();
479    }
480    
481    public void setReferenceValidationPattern(@Nullable String referenceValidationPattern)
482            throws PersistenceNotNullException, PersistenceReadOnlyException {
483        checkReadWrite();
484        _value.setReferenceValidationPattern(referenceValidationPattern);
485    }
486    
487    public boolean getReferenceValidationPatternHasBeenModified() {
488        return _value.getReferenceValidationPatternHasBeenModified();
489    }
490    
491    @Nonnull
492    public Long getFromTime() {
493        return _value.getFromTime();
494    }
495    
496    public void setFromTime(@Nonnull Long fromTime)
497            throws PersistenceNotNullException, PersistenceReadOnlyException {
498        checkReadWrite();
499        _value.setFromTime(fromTime);
500    }
501    
502    public boolean getFromTimeHasBeenModified() {
503        return _value.getFromTimeHasBeenModified();
504    }
505    
506    @Nonnull
507    public Long getThruTime() {
508        return _value.getThruTime();
509    }
510    
511    public void setThruTime(@Nonnull Long thruTime)
512            throws PersistenceNotNullException, PersistenceReadOnlyException {
513        checkReadWrite();
514        _value.setThruTime(thruTime);
515    }
516    
517    public boolean getThruTimeHasBeenModified() {
518        return _value.getThruTimeHasBeenModified();
519    }
520    
521}