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 * DocumentDetailValue.java
021 */
022
023package com.echothree.model.data.document.server.value;
024
025import com.echothree.model.data.document.common.pk.DocumentDetailPK;
026
027import com.echothree.model.data.document.server.factory.DocumentDetailFactory;
028
029import com.echothree.model.data.document.common.pk.DocumentPK;
030import com.echothree.model.data.document.common.pk.DocumentTypePK;
031import com.echothree.model.data.core.common.pk.MimeTypePK;
032
033import com.echothree.util.common.exception.PersistenceCloneException;
034import com.echothree.util.common.exception.PersistenceNotNullException;
035
036import com.echothree.util.server.persistence.BaseValue;
037
038import java.io.Serializable;
039
040public class DocumentDetailValue
041        extends BaseValue<DocumentDetailPK>
042        implements Cloneable, Serializable {
043    
044    private DocumentPK documentPK;
045    private boolean documentPKHasBeenModified = false;
046    private String documentName;
047    private boolean documentNameHasBeenModified = false;
048    private DocumentTypePK documentTypePK;
049    private boolean documentTypePKHasBeenModified = false;
050    private MimeTypePK mimeTypePK;
051    private boolean mimeTypePKHasBeenModified = false;
052    private Integer pages;
053    private boolean pagesHasBeenModified = false;
054    private Long fromTime;
055    private boolean fromTimeHasBeenModified = false;
056    private Long thruTime;
057    private boolean thruTimeHasBeenModified = false;
058    
059    private transient Integer _hashCode = null;
060    private transient String _stringValue = null;
061    
062    private void constructFields(DocumentPK documentPK, String documentName, DocumentTypePK documentTypePK, MimeTypePK mimeTypePK, Integer pages, Long fromTime, Long thruTime)
063            throws PersistenceNotNullException {
064        checkForNull(documentPK);
065        this.documentPK = documentPK;
066        checkForNull(documentName);
067        this.documentName = documentName;
068        checkForNull(documentTypePK);
069        this.documentTypePK = documentTypePK;
070        checkForNull(mimeTypePK);
071        this.mimeTypePK = mimeTypePK;
072        this.pages = pages;
073        checkForNull(fromTime);
074        this.fromTime = fromTime;
075        checkForNull(thruTime);
076        this.thruTime = thruTime;
077    }
078    
079    /** Creates a new instance of DocumentDetailValue */
080    public DocumentDetailValue(DocumentDetailPK documentDetailPK, DocumentPK documentPK, String documentName, DocumentTypePK documentTypePK, MimeTypePK mimeTypePK, Integer pages, Long fromTime, Long thruTime)
081            throws PersistenceNotNullException {
082        super(documentDetailPK);
083        constructFields(documentPK, documentName, documentTypePK, mimeTypePK, pages, fromTime, thruTime);
084    }
085    
086    /** Creates a new instance of DocumentDetailValue */
087    public DocumentDetailValue(DocumentPK documentPK, String documentName, DocumentTypePK documentTypePK, MimeTypePK mimeTypePK, Integer pages, Long fromTime, Long thruTime)
088            throws PersistenceNotNullException {
089        super();
090        constructFields(documentPK, documentName, documentTypePK, mimeTypePK, pages, fromTime, thruTime);
091    }
092    
093   @Override
094   public DocumentDetailFactory getBaseFactoryInstance() {
095        return DocumentDetailFactory.getInstance();
096    }
097    
098    @Override
099    public DocumentDetailValue clone() {
100        Object result;
101        
102        try {
103            result = super.clone();
104        } catch (CloneNotSupportedException cnse) {
105            // This shouldn't happen, fail when it does.
106            throw new PersistenceCloneException(cnse);
107        }
108        
109        return (DocumentDetailValue)result;
110    }
111    
112   @Override
113    public DocumentDetailPK getPrimaryKey() {
114        if(_primaryKey == null) {
115            _primaryKey = new DocumentDetailPK(entityId);
116        }
117        
118        return _primaryKey;
119    }
120    
121    private void clearHashAndString() {
122        _hashCode = null;
123        _stringValue = null;
124    }
125    
126    @Override
127    public int hashCode() {
128        if(_hashCode == null) {
129            int hashCode = 17;
130            
131            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
132            
133            hashCode = 37 * hashCode + ((documentPK != null) ? documentPK.hashCode() : 0);
134            hashCode = 37 * hashCode + ((documentName != null) ? documentName.hashCode() : 0);
135            hashCode = 37 * hashCode + ((documentTypePK != null) ? documentTypePK.hashCode() : 0);
136            hashCode = 37 * hashCode + ((mimeTypePK != null) ? mimeTypePK.hashCode() : 0);
137            hashCode = 37 * hashCode + ((pages != null) ? pages.hashCode() : 0);
138            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
139            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
140            
141            _hashCode = hashCode;
142        }
143        
144        return _hashCode;
145    }
146    
147    @Override
148    public String toString() {
149        if(_stringValue == null) {
150            _stringValue = "{" + 
151                    "entityId=" + getEntityId() +
152                    ", documentPK=" + getDocumentPK() +
153                    ", documentName=" + getDocumentName() +
154                    ", documentTypePK=" + getDocumentTypePK() +
155                    ", mimeTypePK=" + getMimeTypePK() +
156                    ", pages=" + getPages() +
157                    ", fromTime=" + getFromTime() +
158                    ", thruTime=" + getThruTime() +
159                    "}";
160        }
161        return _stringValue;
162    }
163    
164    @Override
165    public boolean equals(Object other) {
166        if(this == other)
167            return true;
168        
169        if(!hasIdentity())
170            return false;
171        
172        if(other instanceof  DocumentDetailValue that) {
173            if(!that.hasIdentity())
174                return false;
175            
176            Long thisEntityId = getEntityId();
177            Long thatEntityId = that.getEntityId();
178            
179            boolean objectsEqual = thisEntityId.equals(thatEntityId);
180            if(objectsEqual)
181                objectsEqual = isIdentical(that);
182            
183            return objectsEqual;
184        } else {
185            return false;
186        }
187    }
188    
189    public boolean isIdentical(Object other) {
190        if(other instanceof DocumentDetailValue that) {
191            boolean objectsEqual = true;
192            
193            
194            if(objectsEqual) {
195                DocumentPK thisDocumentPK = getDocumentPK();
196                DocumentPK thatDocumentPK = that.getDocumentPK();
197                
198                if(thisDocumentPK == null) {
199                    objectsEqual = objectsEqual && (thatDocumentPK == null);
200                } else {
201                    objectsEqual = objectsEqual && thisDocumentPK.equals(thatDocumentPK);
202                }
203            }
204            
205            if(objectsEqual) {
206                String thisDocumentName = getDocumentName();
207                String thatDocumentName = that.getDocumentName();
208                
209                if(thisDocumentName == null) {
210                    objectsEqual = objectsEqual && (thatDocumentName == null);
211                } else {
212                    objectsEqual = objectsEqual && thisDocumentName.equals(thatDocumentName);
213                }
214            }
215            
216            if(objectsEqual) {
217                DocumentTypePK thisDocumentTypePK = getDocumentTypePK();
218                DocumentTypePK thatDocumentTypePK = that.getDocumentTypePK();
219                
220                if(thisDocumentTypePK == null) {
221                    objectsEqual = objectsEqual && (thatDocumentTypePK == null);
222                } else {
223                    objectsEqual = objectsEqual && thisDocumentTypePK.equals(thatDocumentTypePK);
224                }
225            }
226            
227            if(objectsEqual) {
228                MimeTypePK thisMimeTypePK = getMimeTypePK();
229                MimeTypePK thatMimeTypePK = that.getMimeTypePK();
230                
231                if(thisMimeTypePK == null) {
232                    objectsEqual = objectsEqual && (thatMimeTypePK == null);
233                } else {
234                    objectsEqual = objectsEqual && thisMimeTypePK.equals(thatMimeTypePK);
235                }
236            }
237            
238            if(objectsEqual) {
239                Integer thisPages = getPages();
240                Integer thatPages = that.getPages();
241                
242                if(thisPages == null) {
243                    objectsEqual = objectsEqual && (thatPages == null);
244                } else {
245                    objectsEqual = objectsEqual && thisPages.equals(thatPages);
246                }
247            }
248            
249            if(objectsEqual) {
250                Long thisFromTime = getFromTime();
251                Long thatFromTime = that.getFromTime();
252                
253                if(thisFromTime == null) {
254                    objectsEqual = objectsEqual && (thatFromTime == null);
255                } else {
256                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
257                }
258            }
259            
260            if(objectsEqual) {
261                Long thisThruTime = getThruTime();
262                Long thatThruTime = that.getThruTime();
263                
264                if(thisThruTime == null) {
265                    objectsEqual = objectsEqual && (thatThruTime == null);
266                } else {
267                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
268                }
269            }
270            
271            return objectsEqual;
272        } else {
273            return false;
274        }
275    }
276    
277    @Override
278    public boolean hasBeenModified() {
279        return documentPKHasBeenModified || documentNameHasBeenModified || documentTypePKHasBeenModified || mimeTypePKHasBeenModified || pagesHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
280    }
281    
282    @Override
283    public void clearHasBeenModified() {
284        documentPKHasBeenModified = false;
285        documentNameHasBeenModified = false;
286        documentTypePKHasBeenModified = false;
287        mimeTypePKHasBeenModified = false;
288        pagesHasBeenModified = false;
289        fromTimeHasBeenModified = false;
290        thruTimeHasBeenModified = false;
291    }
292    
293    public DocumentPK getDocumentPK() {
294        return documentPK;
295    }
296    
297    public void setDocumentPK(DocumentPK documentPK)
298            throws PersistenceNotNullException {
299        checkForNull(documentPK);
300        
301        boolean update = true;
302        
303        if(this.documentPK != null) {
304            if(this.documentPK.equals(documentPK)) {
305                update = false;
306            }
307        } else if(documentPK == null) {
308            update = false;
309        }
310        
311        if(update) {
312            this.documentPK = documentPK;
313            documentPKHasBeenModified = true;
314            clearHashAndString();
315        }
316    }
317    
318    public boolean getDocumentPKHasBeenModified() {
319        return documentPKHasBeenModified;
320    }
321    
322    public String getDocumentName() {
323        return documentName;
324    }
325    
326    public void setDocumentName(String documentName)
327            throws PersistenceNotNullException {
328        checkForNull(documentName);
329        
330        boolean update = true;
331        
332        if(this.documentName != null) {
333            if(this.documentName.equals(documentName)) {
334                update = false;
335            }
336        } else if(documentName == null) {
337            update = false;
338        }
339        
340        if(update) {
341            this.documentName = documentName;
342            documentNameHasBeenModified = true;
343            clearHashAndString();
344        }
345    }
346    
347    public boolean getDocumentNameHasBeenModified() {
348        return documentNameHasBeenModified;
349    }
350    
351    public DocumentTypePK getDocumentTypePK() {
352        return documentTypePK;
353    }
354    
355    public void setDocumentTypePK(DocumentTypePK documentTypePK)
356            throws PersistenceNotNullException {
357        checkForNull(documentTypePK);
358        
359        boolean update = true;
360        
361        if(this.documentTypePK != null) {
362            if(this.documentTypePK.equals(documentTypePK)) {
363                update = false;
364            }
365        } else if(documentTypePK == null) {
366            update = false;
367        }
368        
369        if(update) {
370            this.documentTypePK = documentTypePK;
371            documentTypePKHasBeenModified = true;
372            clearHashAndString();
373        }
374    }
375    
376    public boolean getDocumentTypePKHasBeenModified() {
377        return documentTypePKHasBeenModified;
378    }
379    
380    public MimeTypePK getMimeTypePK() {
381        return mimeTypePK;
382    }
383    
384    public void setMimeTypePK(MimeTypePK mimeTypePK)
385            throws PersistenceNotNullException {
386        checkForNull(mimeTypePK);
387        
388        boolean update = true;
389        
390        if(this.mimeTypePK != null) {
391            if(this.mimeTypePK.equals(mimeTypePK)) {
392                update = false;
393            }
394        } else if(mimeTypePK == null) {
395            update = false;
396        }
397        
398        if(update) {
399            this.mimeTypePK = mimeTypePK;
400            mimeTypePKHasBeenModified = true;
401            clearHashAndString();
402        }
403    }
404    
405    public boolean getMimeTypePKHasBeenModified() {
406        return mimeTypePKHasBeenModified;
407    }
408    
409    public Integer getPages() {
410        return pages;
411    }
412    
413    public void setPages(Integer pages) {
414        boolean update = true;
415        
416        if(this.pages != null) {
417            if(this.pages.equals(pages)) {
418                update = false;
419            }
420        } else if(pages == null) {
421            update = false;
422        }
423        
424        if(update) {
425            this.pages = pages;
426            pagesHasBeenModified = true;
427            clearHashAndString();
428        }
429    }
430    
431    public boolean getPagesHasBeenModified() {
432        return pagesHasBeenModified;
433    }
434    
435    public Long getFromTime() {
436        return fromTime;
437    }
438    
439    public void setFromTime(Long fromTime)
440            throws PersistenceNotNullException {
441        checkForNull(fromTime);
442        
443        boolean update = true;
444        
445        if(this.fromTime != null) {
446            if(this.fromTime.equals(fromTime)) {
447                update = false;
448            }
449        } else if(fromTime == null) {
450            update = false;
451        }
452        
453        if(update) {
454            this.fromTime = fromTime;
455            fromTimeHasBeenModified = true;
456            clearHashAndString();
457        }
458    }
459    
460    public boolean getFromTimeHasBeenModified() {
461        return fromTimeHasBeenModified;
462    }
463    
464    public Long getThruTime() {
465        return thruTime;
466    }
467    
468    public void setThruTime(Long thruTime)
469            throws PersistenceNotNullException {
470        checkForNull(thruTime);
471        
472        boolean update = true;
473        
474        if(this.thruTime != null) {
475            if(this.thruTime.equals(thruTime)) {
476                update = false;
477            }
478        } else if(thruTime == null) {
479            update = false;
480        }
481        
482        if(update) {
483            this.thruTime = thruTime;
484            thruTimeHasBeenModified = true;
485            clearHashAndString();
486        }
487    }
488    
489    public boolean getThruTimeHasBeenModified() {
490        return thruTimeHasBeenModified;
491    }
492    
493}