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 * ContactMechanismPurpose.java 021 */ 022 023package com.echothree.model.data.contact.server.entity; 024 025import com.echothree.model.data.contact.common.pk.ContactMechanismPurposePK; 026 027import com.echothree.model.data.contact.common.pk.ContactMechanismTypePK; 028 029import com.echothree.model.data.contact.server.entity.ContactMechanismType; 030 031import com.echothree.model.data.contact.server.factory.ContactMechanismTypeFactory; 032 033import com.echothree.model.data.contact.common.pk.ContactMechanismPurposePK; 034 035import com.echothree.model.data.contact.server.value.ContactMechanismPurposeValue; 036 037import com.echothree.model.data.contact.server.factory.ContactMechanismPurposeFactory; 038 039import com.echothree.util.common.exception.PersistenceException; 040import com.echothree.util.common.exception.PersistenceDatabaseException; 041import com.echothree.util.common.exception.PersistenceNotNullException; 042import com.echothree.util.common.exception.PersistenceReadOnlyException; 043 044import com.echothree.util.common.persistence.BasePK; 045 046import com.echothree.util.common.persistence.type.ByteArray; 047 048import com.echothree.util.server.persistence.BaseEntity; 049import com.echothree.util.server.persistence.EntityPermission; 050import com.echothree.util.server.persistence.Session; 051import com.echothree.util.server.persistence.ThreadSession; 052 053import java.io.Serializable; 054 055import javax.annotation.Nonnull; 056import javax.annotation.Nullable; 057 058public class ContactMechanismPurpose 059 extends BaseEntity 060 implements Serializable { 061 062 private ContactMechanismPurposePK _pk; 063 private ContactMechanismPurposeValue _value; 064 065 /** Creates a new instance of ContactMechanismPurpose */ 066 public ContactMechanismPurpose() 067 throws PersistenceException { 068 super(); 069 } 070 071 /** Creates a new instance of ContactMechanismPurpose */ 072 public ContactMechanismPurpose(ContactMechanismPurposeValue value, EntityPermission entityPermission) { 073 super(entityPermission); 074 075 _value = value; 076 _pk = value.getPrimaryKey(); 077 } 078 079 @Override 080 @Nonnull 081 public ContactMechanismPurposeFactory getBaseFactoryInstance() { 082 return ContactMechanismPurposeFactory.getInstance(); 083 } 084 085 @Override 086 public boolean hasBeenModified() { 087 return _value.hasBeenModified(); 088 } 089 090 @Override 091 public int hashCode() { 092 return _pk.hashCode(); 093 } 094 095 @Override 096 @Nonnull 097 public String toString() { 098 return _pk.toString(); 099 } 100 101 @Override 102 public boolean equals(Object other) { 103 if(this == other) 104 return true; 105 106 if(other instanceof ContactMechanismPurpose that) { 107 ContactMechanismPurposeValue thatValue = that.getContactMechanismPurposeValue(); 108 return _value.equals(thatValue); 109 } else { 110 return false; 111 } 112 } 113 114 @Override 115 public void store() 116 throws PersistenceDatabaseException { 117 getBaseFactoryInstance().store(this); 118 } 119 120 @Override 121 public void remove() 122 throws PersistenceDatabaseException { 123 getBaseFactoryInstance().remove(this); 124 } 125 126 @Nonnull 127 public ContactMechanismPurposeValue getContactMechanismPurposeValue() { 128 return _value; 129 } 130 131 public void setContactMechanismPurposeValue(@Nonnull ContactMechanismPurposeValue value) 132 throws PersistenceReadOnlyException { 133 checkReadWrite(); 134 _value = value; 135 } 136 137 @Override 138 @Nonnull 139 public ContactMechanismPurposePK getPrimaryKey() { 140 return _pk; 141 } 142 143 @Nonnull 144 public String getContactMechanismPurposeName() { 145 return _value.getContactMechanismPurposeName(); 146 } 147 148 public void setContactMechanismPurposeName(@Nonnull String contactMechanismPurposeName) 149 throws PersistenceNotNullException, PersistenceReadOnlyException { 150 checkReadWrite(); 151 _value.setContactMechanismPurposeName(contactMechanismPurposeName); 152 } 153 154 public boolean getContactMechanismPurposeNameHasBeenModified() { 155 return _value.getContactMechanismPurposeNameHasBeenModified(); 156 } 157 158 @Nonnull 159 public ContactMechanismTypePK getContactMechanismTypePK() { 160 return _value.getContactMechanismTypePK(); 161 } 162 163 @Nonnull 164 public ContactMechanismType getContactMechanismType(EntityPermission entityPermission) { 165 return ContactMechanismTypeFactory.getInstance().getEntityFromPK(entityPermission, getContactMechanismTypePK()); 166 } 167 168 @Nonnull 169 public ContactMechanismType getContactMechanismType() { 170 return getContactMechanismType(EntityPermission.READ_ONLY); 171 } 172 173 @Nonnull 174 public ContactMechanismType getContactMechanismTypeForUpdate() { 175 return getContactMechanismType(EntityPermission.READ_WRITE); 176 } 177 178 public void setContactMechanismTypePK(@Nonnull ContactMechanismTypePK contactMechanismTypePK) 179 throws PersistenceNotNullException, PersistenceReadOnlyException { 180 checkReadWrite(); 181 _value.setContactMechanismTypePK(contactMechanismTypePK); 182 } 183 184 public void setContactMechanismType(@Nonnull ContactMechanismType entity) { 185 setContactMechanismTypePK(entity == null ? null : entity.getPrimaryKey()); 186 } 187 188 public boolean getContactMechanismTypePKHasBeenModified() { 189 return _value.getContactMechanismTypePKHasBeenModified(); 190 } 191 192 @Nonnull 193 public Boolean getEventSubscriber() { 194 return _value.getEventSubscriber(); 195 } 196 197 public void setEventSubscriber(@Nonnull Boolean eventSubscriber) 198 throws PersistenceNotNullException, PersistenceReadOnlyException { 199 checkReadWrite(); 200 _value.setEventSubscriber(eventSubscriber); 201 } 202 203 public boolean getEventSubscriberHasBeenModified() { 204 return _value.getEventSubscriberHasBeenModified(); 205 } 206 207 @Nonnull 208 public Boolean getIsDefault() { 209 return _value.getIsDefault(); 210 } 211 212 public void setIsDefault(@Nonnull Boolean isDefault) 213 throws PersistenceNotNullException, PersistenceReadOnlyException { 214 checkReadWrite(); 215 _value.setIsDefault(isDefault); 216 } 217 218 public boolean getIsDefaultHasBeenModified() { 219 return _value.getIsDefaultHasBeenModified(); 220 } 221 222 @Nonnull 223 public Integer getSortOrder() { 224 return _value.getSortOrder(); 225 } 226 227 public void setSortOrder(@Nonnull Integer sortOrder) 228 throws PersistenceNotNullException, PersistenceReadOnlyException { 229 checkReadWrite(); 230 _value.setSortOrder(sortOrder); 231 } 232 233 public boolean getSortOrderHasBeenModified() { 234 return _value.getSortOrderHasBeenModified(); 235 } 236 237}