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 * Link.java 021 */ 022 023package com.echothree.model.data.core.server.entity; 024 025import com.echothree.model.data.core.common.pk.LinkPK; 026 027import com.echothree.model.data.core.common.pk.LinkTypePK; 028import com.echothree.model.data.core.common.pk.EntityInstancePK; 029 030import com.echothree.model.data.core.server.entity.LinkType; 031import com.echothree.model.data.core.server.entity.EntityInstance; 032 033import com.echothree.model.data.core.server.factory.LinkTypeFactory; 034import com.echothree.model.data.core.server.factory.EntityInstanceFactory; 035 036import com.echothree.model.data.core.common.pk.LinkPK; 037 038import com.echothree.model.data.core.server.value.LinkValue; 039 040import com.echothree.model.data.core.server.factory.LinkFactory; 041 042import com.echothree.util.common.exception.PersistenceException; 043import com.echothree.util.common.exception.PersistenceDatabaseException; 044import com.echothree.util.common.exception.PersistenceNotNullException; 045import com.echothree.util.common.exception.PersistenceReadOnlyException; 046 047import com.echothree.util.common.persistence.BasePK; 048 049import com.echothree.util.common.persistence.type.ByteArray; 050 051import com.echothree.util.server.persistence.BaseEntity; 052import com.echothree.util.server.persistence.EntityPermission; 053import com.echothree.util.server.persistence.Session; 054import com.echothree.util.server.persistence.ThreadSession; 055 056import java.io.Serializable; 057 058import javax.annotation.Nonnull; 059import javax.annotation.Nullable; 060 061public class Link 062 extends BaseEntity 063 implements Serializable { 064 065 private LinkPK _pk; 066 private LinkValue _value; 067 068 /** Creates a new instance of Link */ 069 public Link() 070 throws PersistenceException { 071 super(); 072 } 073 074 /** Creates a new instance of Link */ 075 public Link(LinkValue value, EntityPermission entityPermission) { 076 super(entityPermission); 077 078 _value = value; 079 _pk = value.getPrimaryKey(); 080 } 081 082 @Override 083 @Nonnull 084 public LinkFactory getBaseFactoryInstance() { 085 return LinkFactory.getInstance(); 086 } 087 088 @Override 089 public boolean hasBeenModified() { 090 return _value.hasBeenModified(); 091 } 092 093 @Override 094 public int hashCode() { 095 return _pk.hashCode(); 096 } 097 098 @Override 099 @Nonnull 100 public String toString() { 101 return _pk.toString(); 102 } 103 104 @Override 105 public boolean equals(Object other) { 106 if(this == other) 107 return true; 108 109 if(other instanceof Link that) { 110 LinkValue thatValue = that.getLinkValue(); 111 return _value.equals(thatValue); 112 } else { 113 return false; 114 } 115 } 116 117 @Override 118 public void store() 119 throws PersistenceDatabaseException { 120 getBaseFactoryInstance().store(this); 121 } 122 123 @Override 124 public void remove() 125 throws PersistenceDatabaseException { 126 getBaseFactoryInstance().remove(this); 127 } 128 129 @Nonnull 130 public LinkValue getLinkValue() { 131 return _value; 132 } 133 134 public void setLinkValue(@Nonnull LinkValue value) 135 throws PersistenceReadOnlyException { 136 checkReadWrite(); 137 _value = value; 138 } 139 140 @Override 141 @Nonnull 142 public LinkPK getPrimaryKey() { 143 return _pk; 144 } 145 146 @Nonnull 147 public LinkTypePK getLinkTypePK() { 148 return _value.getLinkTypePK(); 149 } 150 151 @Nonnull 152 public LinkType getLinkType(EntityPermission entityPermission) { 153 return LinkTypeFactory.getInstance().getEntityFromPK(entityPermission, getLinkTypePK()); 154 } 155 156 @Nonnull 157 public LinkType getLinkType() { 158 return getLinkType(EntityPermission.READ_ONLY); 159 } 160 161 @Nonnull 162 public LinkType getLinkTypeForUpdate() { 163 return getLinkType(EntityPermission.READ_WRITE); 164 } 165 166 public void setLinkTypePK(@Nonnull LinkTypePK linkTypePK) 167 throws PersistenceNotNullException, PersistenceReadOnlyException { 168 checkReadWrite(); 169 _value.setLinkTypePK(linkTypePK); 170 } 171 172 public void setLinkType(@Nonnull LinkType entity) { 173 setLinkTypePK(entity == null ? null : entity.getPrimaryKey()); 174 } 175 176 public boolean getLinkTypePKHasBeenModified() { 177 return _value.getLinkTypePKHasBeenModified(); 178 } 179 180 @Nonnull 181 public EntityInstancePK getSourceEntityInstancePK() { 182 return _value.getSourceEntityInstancePK(); 183 } 184 185 @Nonnull 186 public EntityInstance getSourceEntityInstance(EntityPermission entityPermission) { 187 return EntityInstanceFactory.getInstance().getEntityFromPK(entityPermission, getSourceEntityInstancePK()); 188 } 189 190 @Nonnull 191 public EntityInstance getSourceEntityInstance() { 192 return getSourceEntityInstance(EntityPermission.READ_ONLY); 193 } 194 195 @Nonnull 196 public EntityInstance getSourceEntityInstanceForUpdate() { 197 return getSourceEntityInstance(EntityPermission.READ_WRITE); 198 } 199 200 public void setSourceEntityInstancePK(@Nonnull EntityInstancePK sourceEntityInstancePK) 201 throws PersistenceNotNullException, PersistenceReadOnlyException { 202 checkReadWrite(); 203 _value.setSourceEntityInstancePK(sourceEntityInstancePK); 204 } 205 206 public void setSourceEntityInstance(@Nonnull EntityInstance entity) { 207 setSourceEntityInstancePK(entity == null ? null : entity.getPrimaryKey()); 208 } 209 210 public boolean getSourceEntityInstancePKHasBeenModified() { 211 return _value.getSourceEntityInstancePKHasBeenModified(); 212 } 213 214 @Nonnull 215 public EntityInstancePK getTargetEntityInstancePK() { 216 return _value.getTargetEntityInstancePK(); 217 } 218 219 @Nonnull 220 public EntityInstance getTargetEntityInstance(EntityPermission entityPermission) { 221 return EntityInstanceFactory.getInstance().getEntityFromPK(entityPermission, getTargetEntityInstancePK()); 222 } 223 224 @Nonnull 225 public EntityInstance getTargetEntityInstance() { 226 return getTargetEntityInstance(EntityPermission.READ_ONLY); 227 } 228 229 @Nonnull 230 public EntityInstance getTargetEntityInstanceForUpdate() { 231 return getTargetEntityInstance(EntityPermission.READ_WRITE); 232 } 233 234 public void setTargetEntityInstancePK(@Nonnull EntityInstancePK targetEntityInstancePK) 235 throws PersistenceNotNullException, PersistenceReadOnlyException { 236 checkReadWrite(); 237 _value.setTargetEntityInstancePK(targetEntityInstancePK); 238 } 239 240 public void setTargetEntityInstance(@Nonnull EntityInstance entity) { 241 setTargetEntityInstancePK(entity == null ? null : entity.getPrimaryKey()); 242 } 243 244 public boolean getTargetEntityInstancePKHasBeenModified() { 245 return _value.getTargetEntityInstancePKHasBeenModified(); 246 } 247 248 @Nonnull 249 public Long getFromTime() { 250 return _value.getFromTime(); 251 } 252 253 public void setFromTime(@Nonnull Long fromTime) 254 throws PersistenceNotNullException, PersistenceReadOnlyException { 255 checkReadWrite(); 256 _value.setFromTime(fromTime); 257 } 258 259 public boolean getFromTimeHasBeenModified() { 260 return _value.getFromTimeHasBeenModified(); 261 } 262 263 @Nonnull 264 public Long getThruTime() { 265 return _value.getThruTime(); 266 } 267 268 public void setThruTime(@Nonnull Long thruTime) 269 throws PersistenceNotNullException, PersistenceReadOnlyException { 270 checkReadWrite(); 271 _value.setThruTime(thruTime); 272 } 273 274 public boolean getThruTimeHasBeenModified() { 275 return _value.getThruTimeHasBeenModified(); 276 } 277 278}