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