001package ca.cdr.api.model.json;
002
003/*-
004 * #%L
005 * Smile CDR - CDR
006 * %%
007 * Copyright (C) 2016 - 2026 Smile CDR, Inc.
008 * %%
009 * All rights reserved.
010 * #L%
011 */
012
013import ca.cdr.api.model.json.jackson2deprecated.JsonDateDeserializerJacksonV2Deprecated;
014import ca.cdr.api.model.json.jackson2deprecated.JsonDateSerializerJacksonV2Deprecated;
015import ca.uhn.fhir.model.api.IModelJson;
016import com.fasterxml.jackson.annotation.JsonProperty;
017import io.swagger.v3.oas.annotations.media.Schema;
018import jakarta.validation.constraints.NotBlank;
019import org.apache.commons.lang3.builder.EqualsBuilder;
020import org.apache.commons.lang3.builder.HashCodeBuilder;
021import org.apache.commons.lang3.builder.ToStringBuilder;
022import org.apache.commons.lang3.builder.ToStringStyle;
023import tools.jackson.databind.annotation.JsonDeserialize;
024import tools.jackson.databind.annotation.JsonSerialize;
025
026import java.io.Serializable;
027import java.util.Date;
028
029@Schema(name = "OAuth2ClientSecret", description = "A client secret for an OAuth2 client")
030public class OAuth2ClientSecretJson implements Serializable, IModelJson {
031
032        @JsonProperty("pid")
033        private Long myPid;
034
035        @NotBlank
036        @JsonProperty("secret")
037        private String mySecret;
038
039        @JsonProperty("description")
040        private String myDescription;
041
042        @JsonProperty("expiration")
043        @com.fasterxml.jackson.databind.annotation.JsonSerialize(using = JsonDateSerializerJacksonV2Deprecated.class)
044        @JsonSerialize(using = JsonDateSerializer.class)
045        @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = JsonDateDeserializerJacksonV2Deprecated.class)
046        @JsonDeserialize(using = JsonDateDeserializer.class)
047        private Date myExpiration;
048
049        @JsonProperty("activation")
050        @com.fasterxml.jackson.databind.annotation.JsonSerialize(using = JsonDateSerializerJacksonV2Deprecated.class)
051        @JsonSerialize(using = JsonDateSerializer.class)
052        @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = JsonDateDeserializerJacksonV2Deprecated.class)
053        @JsonDeserialize(using = JsonDateDeserializer.class)
054        private Date myActivation;
055
056        /**
057         * Constructor
058         */
059        public OAuth2ClientSecretJson() {
060                super();
061        }
062
063        public String getDescription() {
064                return myDescription;
065        }
066
067        public OAuth2ClientSecretJson setDescription(String theDescription) {
068                myDescription = theDescription;
069                return this;
070        }
071
072        public Long getPid() {
073                return myPid;
074        }
075
076        public void setPid(Long thePid) {
077                myPid = thePid;
078        }
079
080        public Date getActivation() {
081                return myActivation;
082        }
083
084        public OAuth2ClientSecretJson setActivation(Date theActivation) {
085                myActivation = theActivation;
086                return this;
087        }
088
089        @Override
090        public String toString() {
091                return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
092                                .append("secret", mySecret)
093                                .append("activation", myActivation)
094                                .append("expiration", myExpiration)
095                                .toString();
096        }
097
098        @Override
099        public boolean equals(Object theO) {
100                if (this == theO) {
101                        return true;
102                }
103
104                if (theO == null || getClass() != theO.getClass()) {
105                        return false;
106                }
107
108                OAuth2ClientSecretJson that = (OAuth2ClientSecretJson) theO;
109
110                return new EqualsBuilder()
111                                .append(mySecret, that.mySecret)
112                                .append(myActivation, that.myActivation)
113                                .append(myExpiration, that.myExpiration)
114                                .isEquals();
115        }
116
117        @Override
118        public int hashCode() {
119                return new HashCodeBuilder(17, 37)
120                                .append(mySecret)
121                                .append(myActivation)
122                                .append(myExpiration)
123                                .toHashCode();
124        }
125
126        public String getSecret() {
127                return mySecret;
128        }
129
130        public OAuth2ClientSecretJson setSecret(String theSecret) {
131                mySecret = theSecret;
132                return this;
133        }
134
135        public Date getExpiration() {
136                return myExpiration;
137        }
138
139        public OAuth2ClientSecretJson setExpiration(Date theExpiration) {
140                if (theExpiration != null && theExpiration.getClass().equals(Date.class) == false) {
141                        // java.sql.Date is a subclass of Date, but equals() comparisons don't work well
142                        // and it doesn't add any value, so switch these back to normal dates..
143                        myExpiration = new Date(theExpiration.getTime());
144                } else {
145                        myExpiration = theExpiration;
146                }
147                return this;
148        }
149}