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 com.fasterxml.jackson.annotation.JsonProperty;
014import io.swagger.v3.oas.annotations.media.Schema;
015import org.apache.commons.lang3.builder.EqualsBuilder;
016import org.apache.commons.lang3.builder.HashCodeBuilder;
017import org.apache.commons.lang3.builder.ToStringBuilder;
018import org.apache.commons.lang3.builder.ToStringStyle;
019
020import java.io.Serializable;
021
022/**
023 * Represents a SMART launch context that has been assigned to a specific user session.
024 * This structure uses launch context type (i.e. patient).
025 */
026@Schema(
027                name = "LaunchContext",
028                description = "Represents a SMART launch context that has been assigned to a specific user session. "
029                                + "This structure uses launch context type (i.e. patient).")
030public class LaunchContextJson implements Serializable, IModelJson {
031
032        @JsonProperty("contextType")
033        @Schema(
034                        description =
035                                        "The launch context type, e.g. \"patient\" (note the lack of capitalization in SMART launch scope types)",
036                        example = "patient")
037        private String myContextType;
038
039        @JsonProperty("resourceId")
040        @Schema(
041                        description =
042                                        "The launch context resource ID, e.g. \"123\" (note that the resource type is not included in the ID)",
043                        example = "123")
044        private String myResourceId;
045
046        /**
047         * Constructor
048         */
049        public LaunchContextJson() {
050                super();
051        }
052
053        @Override
054        public boolean equals(Object theO) {
055                if (this == theO) {
056                        return true;
057                }
058
059                if (theO == null || getClass() != theO.getClass()) {
060                        return false;
061                }
062
063                LaunchContextJson that = (LaunchContextJson) theO;
064
065                return new EqualsBuilder()
066                                .append(getContextType(), that.getContextType())
067                                .append(getResourceId(), that.getResourceId())
068                                .isEquals();
069        }
070
071        public String getContextType() {
072                return myContextType;
073        }
074
075        public LaunchContextJson setContextType(String theContextType) {
076                myContextType = theContextType;
077                return this;
078        }
079
080        public String getResourceId() {
081                return myResourceId;
082        }
083
084        public LaunchContextJson setResourceId(String theResourceId) {
085                myResourceId = theResourceId;
086                return this;
087        }
088
089        @Override
090        public int hashCode() {
091                return new HashCodeBuilder(17, 37)
092                                .append(getContextType())
093                                .append(getResourceId())
094                                .toHashCode();
095        }
096
097        @Override
098        public String toString() {
099                return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
100                                .append("contextType", myContextType)
101                                .append("resourceId", myResourceId)
102                                .toString();
103        }
104}