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 * IndexStatusValue.java
021 */
022
023package com.echothree.model.data.index.server.value;
024
025import com.echothree.model.data.index.common.pk.IndexStatusPK;
026
027import com.echothree.model.data.index.server.factory.IndexStatusFactory;
028
029import com.echothree.model.data.index.common.pk.IndexPK;
030
031import com.echothree.util.common.exception.PersistenceCloneException;
032import com.echothree.util.common.exception.PersistenceNotNullException;
033
034import com.echothree.util.server.persistence.BaseValue;
035
036import java.io.Serializable;
037
038public class IndexStatusValue
039        extends BaseValue<IndexStatusPK>
040        implements Cloneable, Serializable {
041    
042    private IndexPK indexPK;
043    private boolean indexPKHasBeenModified = false;
044    private Long createdTime;
045    private boolean createdTimeHasBeenModified = false;
046    
047    private transient Integer _hashCode = null;
048    private transient String _stringValue = null;
049    
050    private void constructFields(IndexPK indexPK, Long createdTime)
051            throws PersistenceNotNullException {
052        checkForNull(indexPK);
053        this.indexPK = indexPK;
054        this.createdTime = createdTime;
055    }
056    
057    /** Creates a new instance of IndexStatusValue */
058    public IndexStatusValue(IndexStatusPK indexStatusPK, IndexPK indexPK, Long createdTime)
059            throws PersistenceNotNullException {
060        super(indexStatusPK);
061        constructFields(indexPK, createdTime);
062    }
063    
064    /** Creates a new instance of IndexStatusValue */
065    public IndexStatusValue(IndexPK indexPK, Long createdTime)
066            throws PersistenceNotNullException {
067        super();
068        constructFields(indexPK, createdTime);
069    }
070    
071   @Override
072   public IndexStatusFactory getBaseFactoryInstance() {
073        return IndexStatusFactory.getInstance();
074    }
075    
076    @Override
077    public IndexStatusValue clone() {
078        Object result;
079        
080        try {
081            result = super.clone();
082        } catch (CloneNotSupportedException cnse) {
083            // This shouldn't happen, fail when it does.
084            throw new PersistenceCloneException(cnse);
085        }
086        
087        return (IndexStatusValue)result;
088    }
089    
090   @Override
091    public IndexStatusPK getPrimaryKey() {
092        if(_primaryKey == null) {
093            _primaryKey = new IndexStatusPK(entityId);
094        }
095        
096        return _primaryKey;
097    }
098    
099    private void clearHashAndString() {
100        _hashCode = null;
101        _stringValue = null;
102    }
103    
104    @Override
105    public int hashCode() {
106        if(_hashCode == null) {
107            int hashCode = 17;
108            
109            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
110            
111            hashCode = 37 * hashCode + ((indexPK != null) ? indexPK.hashCode() : 0);
112            hashCode = 37 * hashCode + ((createdTime != null) ? createdTime.hashCode() : 0);
113            
114            _hashCode = hashCode;
115        }
116        
117        return _hashCode;
118    }
119    
120    @Override
121    public String toString() {
122        if(_stringValue == null) {
123            _stringValue = "{" + 
124                    "entityId=" + getEntityId() +
125                    ", indexPK=" + getIndexPK() +
126                    ", createdTime=" + getCreatedTime() +
127                    "}";
128        }
129        return _stringValue;
130    }
131    
132    @Override
133    public boolean equals(Object other) {
134        if(this == other)
135            return true;
136        
137        if(!hasIdentity())
138            return false;
139        
140        if(other instanceof  IndexStatusValue that) {
141            if(!that.hasIdentity())
142                return false;
143            
144            Long thisEntityId = getEntityId();
145            Long thatEntityId = that.getEntityId();
146            
147            boolean objectsEqual = thisEntityId.equals(thatEntityId);
148            if(objectsEqual)
149                objectsEqual = isIdentical(that);
150            
151            return objectsEqual;
152        } else {
153            return false;
154        }
155    }
156    
157    public boolean isIdentical(Object other) {
158        if(other instanceof IndexStatusValue that) {
159            boolean objectsEqual = true;
160            
161            
162            if(objectsEqual) {
163                IndexPK thisIndexPK = getIndexPK();
164                IndexPK thatIndexPK = that.getIndexPK();
165                
166                if(thisIndexPK == null) {
167                    objectsEqual = objectsEqual && (thatIndexPK == null);
168                } else {
169                    objectsEqual = objectsEqual && thisIndexPK.equals(thatIndexPK);
170                }
171            }
172            
173            if(objectsEqual) {
174                Long thisCreatedTime = getCreatedTime();
175                Long thatCreatedTime = that.getCreatedTime();
176                
177                if(thisCreatedTime == null) {
178                    objectsEqual = objectsEqual && (thatCreatedTime == null);
179                } else {
180                    objectsEqual = objectsEqual && thisCreatedTime.equals(thatCreatedTime);
181                }
182            }
183            
184            return objectsEqual;
185        } else {
186            return false;
187        }
188    }
189    
190    @Override
191    public boolean hasBeenModified() {
192        return indexPKHasBeenModified || createdTimeHasBeenModified;
193    }
194    
195    @Override
196    public void clearHasBeenModified() {
197        indexPKHasBeenModified = false;
198        createdTimeHasBeenModified = false;
199    }
200    
201    public IndexPK getIndexPK() {
202        return indexPK;
203    }
204    
205    public void setIndexPK(IndexPK indexPK)
206            throws PersistenceNotNullException {
207        checkForNull(indexPK);
208        
209        boolean update = true;
210        
211        if(this.indexPK != null) {
212            if(this.indexPK.equals(indexPK)) {
213                update = false;
214            }
215        } else if(indexPK == null) {
216            update = false;
217        }
218        
219        if(update) {
220            this.indexPK = indexPK;
221            indexPKHasBeenModified = true;
222            clearHashAndString();
223        }
224    }
225    
226    public boolean getIndexPKHasBeenModified() {
227        return indexPKHasBeenModified;
228    }
229    
230    public Long getCreatedTime() {
231        return createdTime;
232    }
233    
234    public void setCreatedTime(Long createdTime) {
235        boolean update = true;
236        
237        if(this.createdTime != null) {
238            if(this.createdTime.equals(createdTime)) {
239                update = false;
240            }
241        } else if(createdTime == null) {
242            update = false;
243        }
244        
245        if(update) {
246            this.createdTime = createdTime;
247            createdTimeHasBeenModified = true;
248            clearHashAndString();
249        }
250    }
251    
252    public boolean getCreatedTimeHasBeenModified() {
253        return createdTimeHasBeenModified;
254    }
255    
256}