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