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 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 uuid; 029 private String entityRef; 030 private EntityTimeTransfer entityTime; 031 private String description; 032 033 private EntityAppearanceTransfer entityAppearance; 034 private EntityVisitTransfer entityVisit; 035 private EntityNames entityNames; 036 037 /** Creates a new instance of EntityInstanceTransfer */ 038 public EntityInstanceTransfer(EntityTypeTransfer entityType, Long entityUniqueId, String uuid, 039 String entityRef, EntityTimeTransfer entityTime, String description) { 040 this.entityType = entityType; 041 this.entityUniqueId = entityUniqueId; 042 this.uuid = uuid; 043 this.entityRef = entityRef; 044 this.entityTime = entityTime; 045 this.description = description; 046 } 047 048 public EntityTypeTransfer getEntityType() { 049 return entityType; 050 } 051 052 public void setEntityType(EntityTypeTransfer entityType) { 053 this.entityType = entityType; 054 } 055 056 public Long getEntityUniqueId() { 057 return entityUniqueId; 058 } 059 060 public void setEntityUniqueId(Long entityUniqueId) { 061 this.entityUniqueId = entityUniqueId; 062 } 063 064 public String getUuid() { 065 return uuid; 066 } 067 068 public void setUuid(String uuid) { 069 this.uuid = uuid; 070 } 071 072 public String getEntityRef() { 073 if(entityRef == null) { 074 entityRef = entityType.getComponentVendor().getComponentVendorName() + '.' + entityType.getEntityTypeName() + '.' + entityUniqueId; 075 } 076 077 return entityRef; 078 } 079 080 public void setEntityRef(String entityRef) { 081 this.entityRef = entityRef; 082 } 083 084 public EntityTimeTransfer getEntityTime() { 085 return entityTime; 086 } 087 088 public void setEntityTime(EntityTimeTransfer entityTime) { 089 this.entityTime = entityTime; 090 } 091 092 public String getDescription() { 093 if(description == null) { 094 description = entityType.getDescription() + '-' + entityUniqueId; 095 } 096 097 return description; 098 } 099 100 public void setDescription(String description) { 101 this.description = description; 102 } 103 104 public EntityAppearanceTransfer getEntityAppearance() { 105 return entityAppearance; 106 } 107 108 public void setEntityAppearance(EntityAppearanceTransfer entityAppearance) { 109 this.entityAppearance = entityAppearance; 110 } 111 112 public EntityVisitTransfer getEntityVisit() { 113 return entityVisit; 114 } 115 116 public void setEntityVisit(EntityVisitTransfer entityVisit) { 117 this.entityVisit = entityVisit; 118 } 119 120 public EntityNames getEntityNames() { 121 return entityNames; 122 } 123 124 public void setEntityNames(EntityNames entityNames) { 125 this.entityNames = entityNames; 126 } 127 128 /** entityType and entityUniqueId must be present. 129 */ 130 @Override 131 public boolean equals(Object o) { 132 if(this == o) { 133 return true; 134 } 135 if(o == null || getClass() != o.getClass()) { 136 return false; 137 } 138 var that = (EntityInstanceTransfer) o; 139 return entityType.equals(that.entityType) && entityUniqueId.equals(that.entityUniqueId); 140 } 141 142 /** entityType and entityUniqueId must be present. 143 */ 144 @Override 145 public int hashCode() { 146 return Objects.hash(entityType, entityUniqueId); 147 } 148}