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 * 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            StringBuilder stringValue = new StringBuilder("{");
124            
125            stringValue.append("entityId=").append(getEntityId());
126            
127            stringValue.append(", indexPK=").append(getIndexPK());
128            stringValue.append(", createdTime=").append(getCreatedTime());
129            
130            stringValue.append('}');
131            
132            _stringValue = stringValue.toString();
133        }
134        return _stringValue;
135    }
136    
137    @Override
138    public boolean equals(Object other) {
139        if(this == other)
140            return true;
141        
142        if(!hasIdentity())
143            return false;
144        
145        if(other instanceof  IndexStatusValue) {
146            IndexStatusValue that = (IndexStatusValue)other;
147            
148            if(!that.hasIdentity())
149                return false;
150            
151            Long thisEntityId = getEntityId();
152            Long thatEntityId = that.getEntityId();
153            
154            boolean objectsEqual = thisEntityId.equals(thatEntityId);
155            if(objectsEqual)
156                objectsEqual = objectsEqual && isIdentical(that);
157            
158            return objectsEqual;
159        } else {
160            return false;
161        }
162    }
163    
164    public boolean isIdentical(Object other) {
165        if(other instanceof IndexStatusValue) {
166            IndexStatusValue that = (IndexStatusValue)other;
167            boolean objectsEqual = true;
168            
169            
170            if(objectsEqual) {
171                IndexPK thisIndexPK = getIndexPK();
172                IndexPK thatIndexPK = that.getIndexPK();
173                
174                if(thisIndexPK == null) {
175                    objectsEqual = objectsEqual && (thatIndexPK == null);
176                } else {
177                    objectsEqual = objectsEqual && thisIndexPK.equals(thatIndexPK);
178                }
179            }
180            
181            if(objectsEqual) {
182                Long thisCreatedTime = getCreatedTime();
183                Long thatCreatedTime = that.getCreatedTime();
184                
185                if(thisCreatedTime == null) {
186                    objectsEqual = objectsEqual && (thatCreatedTime == null);
187                } else {
188                    objectsEqual = objectsEqual && thisCreatedTime.equals(thatCreatedTime);
189                }
190            }
191            
192            return objectsEqual;
193        } else {
194            return false;
195        }
196    }
197    
198    @Override
199    public boolean hasBeenModified() {
200        return indexPKHasBeenModified || createdTimeHasBeenModified;
201    }
202    
203    @Override
204    public void clearHasBeenModified() {
205        indexPKHasBeenModified = false;
206        createdTimeHasBeenModified = false;
207    }
208    
209    public IndexPK getIndexPK() {
210        return indexPK;
211    }
212    
213    public void setIndexPK(IndexPK indexPK)
214            throws PersistenceNotNullException {
215        checkForNull(indexPK);
216        
217        boolean update = true;
218        
219        if(this.indexPK != null) {
220            if(this.indexPK.equals(indexPK)) {
221                update = false;
222            }
223        } else if(indexPK == null) {
224            update = false;
225        }
226        
227        if(update) {
228            this.indexPK = indexPK;
229            indexPKHasBeenModified = true;
230            clearHashAndString();
231        }
232    }
233    
234    public boolean getIndexPKHasBeenModified() {
235        return indexPKHasBeenModified;
236    }
237    
238    public Long getCreatedTime() {
239        return createdTime;
240    }
241    
242    public void setCreatedTime(Long createdTime) {
243        boolean update = true;
244        
245        if(this.createdTime != null) {
246            if(this.createdTime.equals(createdTime)) {
247                update = false;
248            }
249        } else if(createdTime == null) {
250            update = false;
251        }
252        
253        if(update) {
254            this.createdTime = createdTime;
255            createdTimeHasBeenModified = true;
256            clearHashAndString();
257        }
258    }
259    
260    public boolean getCreatedTimeHasBeenModified() {
261        return createdTimeHasBeenModified;
262    }
263    
264}