001// --------------------------------------------------------------------------------
002// Copyright 2002-2024 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            StringBuilder stringValue = new StringBuilder("{");
151            
152            stringValue.append("entityId=").append(getEntityId());
153            
154            stringValue.append(", documentPK=").append(getDocumentPK());
155            stringValue.append(", documentName=").append(getDocumentName());
156            stringValue.append(", documentTypePK=").append(getDocumentTypePK());
157            stringValue.append(", mimeTypePK=").append(getMimeTypePK());
158            stringValue.append(", pages=").append(getPages());
159            stringValue.append(", fromTime=").append(getFromTime());
160            stringValue.append(", thruTime=").append(getThruTime());
161            
162            stringValue.append('}');
163            
164            _stringValue = stringValue.toString();
165        }
166        return _stringValue;
167    }
168    
169    @Override
170    public boolean equals(Object other) {
171        if(this == other)
172            return true;
173        
174        if(!hasIdentity())
175            return false;
176        
177        if(other instanceof  DocumentDetailValue) {
178            DocumentDetailValue that = (DocumentDetailValue)other;
179            
180            if(!that.hasIdentity())
181                return false;
182            
183            Long thisEntityId = getEntityId();
184            Long thatEntityId = that.getEntityId();
185            
186            boolean objectsEqual = thisEntityId.equals(thatEntityId);
187            if(objectsEqual)
188                objectsEqual = objectsEqual && isIdentical(that);
189            
190            return objectsEqual;
191        } else {
192            return false;
193        }
194    }
195    
196    public boolean isIdentical(Object other) {
197        if(other instanceof DocumentDetailValue) {
198            DocumentDetailValue that = (DocumentDetailValue)other;
199            boolean objectsEqual = true;
200            
201            
202            if(objectsEqual) {
203                DocumentPK thisDocumentPK = getDocumentPK();
204                DocumentPK thatDocumentPK = that.getDocumentPK();
205                
206                if(thisDocumentPK == null) {
207                    objectsEqual = objectsEqual && (thatDocumentPK == null);
208                } else {
209                    objectsEqual = objectsEqual && thisDocumentPK.equals(thatDocumentPK);
210                }
211            }
212            
213            if(objectsEqual) {
214                String thisDocumentName = getDocumentName();
215                String thatDocumentName = that.getDocumentName();
216                
217                if(thisDocumentName == null) {
218                    objectsEqual = objectsEqual && (thatDocumentName == null);
219                } else {
220                    objectsEqual = objectsEqual && thisDocumentName.equals(thatDocumentName);
221                }
222            }
223            
224            if(objectsEqual) {
225                DocumentTypePK thisDocumentTypePK = getDocumentTypePK();
226                DocumentTypePK thatDocumentTypePK = that.getDocumentTypePK();
227                
228                if(thisDocumentTypePK == null) {
229                    objectsEqual = objectsEqual && (thatDocumentTypePK == null);
230                } else {
231                    objectsEqual = objectsEqual && thisDocumentTypePK.equals(thatDocumentTypePK);
232                }
233            }
234            
235            if(objectsEqual) {
236                MimeTypePK thisMimeTypePK = getMimeTypePK();
237                MimeTypePK thatMimeTypePK = that.getMimeTypePK();
238                
239                if(thisMimeTypePK == null) {
240                    objectsEqual = objectsEqual && (thatMimeTypePK == null);
241                } else {
242                    objectsEqual = objectsEqual && thisMimeTypePK.equals(thatMimeTypePK);
243                }
244            }
245            
246            if(objectsEqual) {
247                Integer thisPages = getPages();
248                Integer thatPages = that.getPages();
249                
250                if(thisPages == null) {
251                    objectsEqual = objectsEqual && (thatPages == null);
252                } else {
253                    objectsEqual = objectsEqual && thisPages.equals(thatPages);
254                }
255            }
256            
257            if(objectsEqual) {
258                Long thisFromTime = getFromTime();
259                Long thatFromTime = that.getFromTime();
260                
261                if(thisFromTime == null) {
262                    objectsEqual = objectsEqual && (thatFromTime == null);
263                } else {
264                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
265                }
266            }
267            
268            if(objectsEqual) {
269                Long thisThruTime = getThruTime();
270                Long thatThruTime = that.getThruTime();
271                
272                if(thisThruTime == null) {
273                    objectsEqual = objectsEqual && (thatThruTime == null);
274                } else {
275                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
276                }
277            }
278            
279            return objectsEqual;
280        } else {
281            return false;
282        }
283    }
284    
285    @Override
286    public boolean hasBeenModified() {
287        return documentPKHasBeenModified || documentNameHasBeenModified || documentTypePKHasBeenModified || mimeTypePKHasBeenModified || pagesHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
288    }
289    
290    @Override
291    public void clearHasBeenModified() {
292        documentPKHasBeenModified = false;
293        documentNameHasBeenModified = false;
294        documentTypePKHasBeenModified = false;
295        mimeTypePKHasBeenModified = false;
296        pagesHasBeenModified = false;
297        fromTimeHasBeenModified = false;
298        thruTimeHasBeenModified = false;
299    }
300    
301    public DocumentPK getDocumentPK() {
302        return documentPK;
303    }
304    
305    public void setDocumentPK(DocumentPK documentPK)
306            throws PersistenceNotNullException {
307        checkForNull(documentPK);
308        
309        boolean update = true;
310        
311        if(this.documentPK != null) {
312            if(this.documentPK.equals(documentPK)) {
313                update = false;
314            }
315        } else if(documentPK == null) {
316            update = false;
317        }
318        
319        if(update) {
320            this.documentPK = documentPK;
321            documentPKHasBeenModified = true;
322            clearHashAndString();
323        }
324    }
325    
326    public boolean getDocumentPKHasBeenModified() {
327        return documentPKHasBeenModified;
328    }
329    
330    public String getDocumentName() {
331        return documentName;
332    }
333    
334    public void setDocumentName(String documentName)
335            throws PersistenceNotNullException {
336        checkForNull(documentName);
337        
338        boolean update = true;
339        
340        if(this.documentName != null) {
341            if(this.documentName.equals(documentName)) {
342                update = false;
343            }
344        } else if(documentName == null) {
345            update = false;
346        }
347        
348        if(update) {
349            this.documentName = documentName;
350            documentNameHasBeenModified = true;
351            clearHashAndString();
352        }
353    }
354    
355    public boolean getDocumentNameHasBeenModified() {
356        return documentNameHasBeenModified;
357    }
358    
359    public DocumentTypePK getDocumentTypePK() {
360        return documentTypePK;
361    }
362    
363    public void setDocumentTypePK(DocumentTypePK documentTypePK)
364            throws PersistenceNotNullException {
365        checkForNull(documentTypePK);
366        
367        boolean update = true;
368        
369        if(this.documentTypePK != null) {
370            if(this.documentTypePK.equals(documentTypePK)) {
371                update = false;
372            }
373        } else if(documentTypePK == null) {
374            update = false;
375        }
376        
377        if(update) {
378            this.documentTypePK = documentTypePK;
379            documentTypePKHasBeenModified = true;
380            clearHashAndString();
381        }
382    }
383    
384    public boolean getDocumentTypePKHasBeenModified() {
385        return documentTypePKHasBeenModified;
386    }
387    
388    public MimeTypePK getMimeTypePK() {
389        return mimeTypePK;
390    }
391    
392    public void setMimeTypePK(MimeTypePK mimeTypePK)
393            throws PersistenceNotNullException {
394        checkForNull(mimeTypePK);
395        
396        boolean update = true;
397        
398        if(this.mimeTypePK != null) {
399            if(this.mimeTypePK.equals(mimeTypePK)) {
400                update = false;
401            }
402        } else if(mimeTypePK == null) {
403            update = false;
404        }
405        
406        if(update) {
407            this.mimeTypePK = mimeTypePK;
408            mimeTypePKHasBeenModified = true;
409            clearHashAndString();
410        }
411    }
412    
413    public boolean getMimeTypePKHasBeenModified() {
414        return mimeTypePKHasBeenModified;
415    }
416    
417    public Integer getPages() {
418        return pages;
419    }
420    
421    public void setPages(Integer pages) {
422        boolean update = true;
423        
424        if(this.pages != null) {
425            if(this.pages.equals(pages)) {
426                update = false;
427            }
428        } else if(pages == null) {
429            update = false;
430        }
431        
432        if(update) {
433            this.pages = pages;
434            pagesHasBeenModified = true;
435            clearHashAndString();
436        }
437    }
438    
439    public boolean getPagesHasBeenModified() {
440        return pagesHasBeenModified;
441    }
442    
443    public Long getFromTime() {
444        return fromTime;
445    }
446    
447    public void setFromTime(Long fromTime)
448            throws PersistenceNotNullException {
449        checkForNull(fromTime);
450        
451        boolean update = true;
452        
453        if(this.fromTime != null) {
454            if(this.fromTime.equals(fromTime)) {
455                update = false;
456            }
457        } else if(fromTime == null) {
458            update = false;
459        }
460        
461        if(update) {
462            this.fromTime = fromTime;
463            fromTimeHasBeenModified = true;
464            clearHashAndString();
465        }
466    }
467    
468    public boolean getFromTimeHasBeenModified() {
469        return fromTimeHasBeenModified;
470    }
471    
472    public Long getThruTime() {
473        return thruTime;
474    }
475    
476    public void setThruTime(Long thruTime)
477            throws PersistenceNotNullException {
478        checkForNull(thruTime);
479        
480        boolean update = true;
481        
482        if(this.thruTime != null) {
483            if(this.thruTime.equals(thruTime)) {
484                update = false;
485            }
486        } else if(thruTime == null) {
487            update = false;
488        }
489        
490        if(update) {
491            this.thruTime = thruTime;
492            thruTimeHasBeenModified = true;
493            clearHashAndString();
494        }
495    }
496    
497    public boolean getThruTimeHasBeenModified() {
498        return thruTimeHasBeenModified;
499    }
500    
501}