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
017package com.echothree.model.control.core.common.transfer;
018
019import com.echothree.util.common.persistence.EntityNames;
020import com.echothree.util.common.transfer.BaseTransfer;
021import java.util.Objects;
022
023public final class EntityInstanceTransfer
024        extends BaseTransfer {
025
026    private EntityTypeTransfer entityType;
027    private Long entityUniqueId;
028    private String key;
029    private String guid;
030    private String ulid;
031    private String entityRef;
032    private EntityTimeTransfer entityTime;
033    private String description;
034    
035    private EntityAppearanceTransfer entityAppearance;
036    private EntityVisitTransfer entityVisit;
037    private EntityNames entityNames;
038
039    /** Creates a new instance of EntityInstanceTransfer */
040    public EntityInstanceTransfer(EntityTypeTransfer entityType, Long entityUniqueId, String key, String guid, String ulid,
041            String entityRef, EntityTimeTransfer entityTime, String description) {
042        this.entityType = entityType;
043        this.entityUniqueId = entityUniqueId;
044        this.key = key;
045        this.guid = guid;
046        this.ulid = ulid;
047        this.entityRef = entityRef;
048        this.entityTime = entityTime;
049        this.description = description;
050    }
051    
052    public EntityTypeTransfer getEntityType() {
053        return entityType;
054    }
055    
056    public void setEntityType(EntityTypeTransfer entityType) {
057        this.entityType = entityType;
058    }
059    
060    public Long getEntityUniqueId() {
061        return entityUniqueId;
062    }
063    
064    public void setEntityUniqueId(Long entityUniqueId) {
065        this.entityUniqueId = entityUniqueId;
066    }
067    
068    public String getKey() {
069        return key;
070    }
071    
072    public void setKey(String key) {
073        this.key = key;
074    }
075    
076    public String getGuid() {
077        return guid;
078    }
079    
080    public void setGuid(String guid) {
081        this.guid = guid;
082    }
083    
084    public String getUlid() {
085        return ulid;
086    }
087
088    public void setUlid(String ulid) {
089        this.ulid = ulid;
090    }
091
092    public String getEntityRef() {
093        if(entityRef == null) {
094            entityRef = new StringBuilder(entityType.getComponentVendor().getComponentVendorName()).append('.').append(entityType.getEntityTypeName()).append('.').append(entityUniqueId).toString();
095        }
096        
097        return entityRef;
098    }
099    
100    public void setEntityRef(String entityRef) {
101        this.entityRef = entityRef;
102    }
103
104    public EntityTimeTransfer getEntityTime() {
105        return entityTime;
106    }
107
108    public void setEntityTime(EntityTimeTransfer entityTime) {
109        this.entityTime = entityTime;
110    }
111
112    public String getDescription() {
113        if(description == null) {
114            description = new StringBuilder(entityType.getDescription()).append('-').append(entityUniqueId).toString();
115        }
116        
117        return description;
118    }
119    
120    public void setDescription(String description) {
121        this.description = description;
122    }
123    
124    public EntityAppearanceTransfer getEntityAppearance() {
125        return entityAppearance;
126    }
127    
128    public void setEntityAppearance(EntityAppearanceTransfer entityAppearance) {
129        this.entityAppearance = entityAppearance;
130    }
131
132    public EntityVisitTransfer getEntityVisit() {
133        return entityVisit;
134    }
135
136    public void setEntityVisit(EntityVisitTransfer entityVisit) {
137        this.entityVisit = entityVisit;
138    }
139
140    public EntityNames getEntityNames() {
141        return entityNames;
142    }
143    
144    public void setEntityNames(EntityNames entityNames) {
145        this.entityNames = entityNames;
146    }
147
148    /** entityType and entityUniqueId must be present.
149     */
150    @Override
151    public boolean equals(Object o) {
152        if(this == o) {
153            return true;
154        }
155        if(o == null || getClass() != o.getClass()) {
156            return false;
157        }
158        EntityInstanceTransfer that = (EntityInstanceTransfer) o;
159        return entityType.equals(that.entityType) && entityUniqueId.equals(that.entityUniqueId);
160    }
161
162    /** entityType and entityUniqueId must be present.
163     */
164    @Override
165    public int hashCode() {
166        return Objects.hash(entityType, entityUniqueId);
167    }
168}