001package ca.cdr.api.model.json;
002
003/*
004 * #%L
005 * Smile CDR - CDR
006 * %%
007 * Copyright (C) 2016 - 2024 Smile CDR, Inc.
008 * %%
009 * All rights reserved.
010 * #L%
011 */
012
013import ca.cdr.api.validator.enm.RequestValidatingResultEnum;
014import com.fasterxml.jackson.annotation.JsonProperty;
015import jakarta.validation.constraints.NotBlank;
016import org.apache.commons.lang3.builder.EqualsBuilder;
017import org.apache.commons.lang3.builder.HashCodeBuilder;
018
019public class AuditEventTargetResourceJson implements IModelJson {
020
021        @NotBlank
022        @JsonProperty("persistenceModuleModuleId")
023        private String myPersistenceModuleModuleId;
024
025        @NotBlank
026        @JsonProperty("persistenceModuleNodeId")
027        private String myPersistenceModuleNodeId;
028
029        @NotBlank
030        @JsonProperty("resourceId")
031        private String myResourceId;
032
033        @JsonProperty("resourceVersion")
034        private Long myResourceVersion;
035
036        @JsonProperty("resourceVersionString")
037        private String myResourceVersionString;
038
039        @JsonProperty("requestValidatingResult")
040        private RequestValidatingResultEnum myRequestValidatingResult;
041
042        /**
043         * Constructor
044         */
045        public AuditEventTargetResourceJson() {
046                super();
047        }
048
049        /**
050         * Constructor
051         */
052        public AuditEventTargetResourceJson(String theResourceId, Long theResourceVersion) {
053                myResourceId = theResourceId;
054                myResourceVersion = theResourceVersion;
055        }
056
057        /**
058         * Copy constructor
059         *
060         * @param theResource The object to copy
061         */
062        public AuditEventTargetResourceJson(AuditEventTargetResourceJson theResource) {
063                myPersistenceModuleNodeId = theResource.getPersistenceModuleNodeId();
064                myPersistenceModuleModuleId = theResource.getPersistenceModuleModuleId();
065                myRequestValidatingResult = theResource.getRequestValidatingResult();
066                myResourceId = theResource.getResourceId();
067                myResourceVersion = theResource.getResourceVersion();
068                myResourceVersionString = theResource.getResourceVersionString();
069        }
070
071        @Override
072        public boolean equals(Object theO) {
073                if (this == theO) {
074                        return true;
075                }
076
077                if (theO == null || getClass() != theO.getClass()) {
078                        return false;
079                }
080
081                AuditEventTargetResourceJson that = (AuditEventTargetResourceJson) theO;
082
083                return new EqualsBuilder()
084                                .append(myPersistenceModuleModuleId, that.myPersistenceModuleModuleId)
085                                .append(myPersistenceModuleNodeId, that.myPersistenceModuleNodeId)
086                                .append(myResourceId, that.myResourceId)
087                                .append(myResourceVersion, that.myResourceVersion)
088                                .append(myResourceVersionString, that.myResourceVersionString)
089                                .append(myRequestValidatingResult, that.myRequestValidatingResult)
090                                .isEquals();
091        }
092
093        @Override
094        public int hashCode() {
095                return new HashCodeBuilder(17, 37)
096                                .append(myPersistenceModuleModuleId)
097                                .append(myPersistenceModuleNodeId)
098                                .append(myResourceId)
099                                .append(myResourceVersion)
100                                .append(myResourceVersionString)
101                                .append(myRequestValidatingResult)
102                                .toHashCode();
103        }
104
105        public String getPersistenceModuleModuleId() {
106                return myPersistenceModuleModuleId;
107        }
108
109        public void setPersistenceModuleModuleId(String theModuleId) {
110                myPersistenceModuleModuleId = theModuleId;
111        }
112
113        public String getPersistenceModuleNodeId() {
114                return myPersistenceModuleNodeId;
115        }
116
117        public void setPersistenceModuleNodeId(String theNodeId) {
118                myPersistenceModuleNodeId = theNodeId;
119        }
120
121        public RequestValidatingResultEnum getRequestValidatingResult() {
122                return myRequestValidatingResult;
123        }
124
125        public void setRequestValidatingResult(RequestValidatingResultEnum theRequestValidatingResult) {
126                myRequestValidatingResult = theRequestValidatingResult;
127        }
128
129        public String getResourceId() {
130                return myResourceId;
131        }
132
133        public void setResourceId(String theResourceId) {
134                myResourceId = theResourceId;
135        }
136
137        public Long getResourceVersion() {
138                return myResourceVersion;
139        }
140
141        public void setResourceVersion(Long theResourceVersion) {
142                myResourceVersion = theResourceVersion;
143        }
144
145        public boolean hasResourceVersion() {
146                return myResourceVersion != null;
147        }
148
149        public String getResourceVersionString() {
150                return myResourceVersionString;
151        }
152
153        public void setResourceVersionString(String theResourceVersionString) {
154                myResourceVersionString = theResourceVersionString;
155        }
156
157        public AuditEventTargetResourceJson toVersionless() {
158                AuditEventTargetResourceJson retVal = new AuditEventTargetResourceJson(this);
159                retVal.setResourceVersionString(null);
160                retVal.setResourceVersion(null);
161                return retVal;
162        }
163}