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