001package ca.uhn.fhir.jpa.model.entity;
002
003/*-
004 * #%L
005 * HAPI FHIR JPA Model
006 * %%
007 * Copyright (C) 2014 - 2025 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import jakarta.persistence.Column;
024import jakarta.persistence.Embeddable;
025
026import java.io.Serializable;
027import java.util.Objects;
028
029@Embeddable
030public class PersistedResourceModifiedMessageEntityPK implements IPersistedResourceModifiedMessagePK, Serializable {
031
032        @Column(name = "RES_ID", length = 256, nullable = false)
033        private String myResourcePid;
034
035        @Column(name = "RES_VER", length = 8, nullable = false)
036        private String myResourceVersion;
037
038        @Column(name = "RESOURCE_TYPE", length = ResourceTable.RESTYPE_LEN, nullable = false)
039        private String myResourceType;
040
041        public String getResourcePid() {
042                return myResourcePid;
043        }
044
045        public PersistedResourceModifiedMessageEntityPK setResourcePid(String theResourcePid) {
046                myResourcePid = theResourcePid;
047                return this;
048        }
049
050        public String getResourceVersion() {
051                return myResourceVersion;
052        }
053
054        public PersistedResourceModifiedMessageEntityPK setResourceVersion(String theResourceVersion) {
055                myResourceVersion = theResourceVersion;
056                return this;
057        }
058
059        public String getResourceType() {
060                return myResourceType;
061        }
062
063        public PersistedResourceModifiedMessageEntityPK setResourceType(String theResourceType) {
064                myResourceType = theResourceType;
065                return this;
066        }
067
068        public static PersistedResourceModifiedMessageEntityPK with(
069                        String theResourcePid, String theResourceVersion, String theResourceType) {
070                return new PersistedResourceModifiedMessageEntityPK()
071                                .setResourcePid(theResourcePid)
072                                .setResourceVersion(theResourceVersion)
073                                .setResourceType(theResourceType);
074        }
075
076        @Override
077        public boolean equals(Object theO) {
078                if (this == theO) return true;
079                if (theO == null || getClass() != theO.getClass()) return false;
080                PersistedResourceModifiedMessageEntityPK that = (PersistedResourceModifiedMessageEntityPK) theO;
081                return myResourcePid.equals(that.myResourcePid)
082                                && myResourceVersion.equals(that.myResourceVersion)
083                                && myResourceType.equals(that.myResourceType);
084        }
085
086        @Override
087        public int hashCode() {
088                return Objects.hash(myResourcePid, myResourceVersion, myResourceType);
089        }
090
091        @Override
092        public String toString() {
093                return myResourceType + "/" + myResourcePid + "/" + myResourceVersion;
094        }
095}