001/*-------------------------------------------------------------------------+
002|                                                                          |
003| Copyright 2005-2011 the ConQAT Project                                   |
004|                                                                          |
005| Licensed under the Apache License, Version 2.0 (the "License");          |
006| you may not use this file except in compliance with the License.         |
007| You may obtain a copy of the License at                                  |
008|                                                                          |
009|    http://www.apache.org/licenses/LICENSE-2.0                            |
010|                                                                          |
011| Unless required by applicable law or agreed to in writing, software      |
012| distributed under the License is distributed on an "AS IS" BASIS,        |
013| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
014| See the License for the specific language governing permissions and      |
015| limitations under the License.                                           |
016+-------------------------------------------------------------------------*/
017package org.conqat.engine.service.shared.data;
018
019import com.fasterxml.jackson.annotation.JsonProperty;
020import com.google.common.base.Objects;
021
022/**
023 * Transport object providing information about the server.
024 */
025public class ServiceApiInfo {
026
027        /** The current version of the service API */
028        @JsonProperty("apiVersion")
029        private final int apiVersion;
030
031        /** The minimum version of the service API still supported by the server */
032        @JsonProperty("minSupportedApiVersion")
033        private final int minSupportedApiVersion;
034
035        /**
036         * An URL (mailto or http) with contact information in case of problems (e.g.
037         * the server admin's email).
038         */
039        @JsonProperty("adminContactUrl")
040        private final String adminContactUrl;
041
042        /** Constructor */
043        public ServiceApiInfo(int apiVersion, int minSupportedApiVersion, String adminContactUrl) {
044                this.apiVersion = apiVersion;
045                this.minSupportedApiVersion = minSupportedApiVersion;
046                this.adminContactUrl = adminContactUrl;
047        }
048
049        /** Returns apiVersion. */
050        public int getApiVersion() {
051                return apiVersion;
052        }
053
054        /** Returns minSupportedApiVersion. */
055        public int getMinSupportedApiVersion() {
056                return minSupportedApiVersion;
057        }
058
059        /** Returns adminContextUrl. */
060        public String getAdminContextUrl() {
061                return adminContactUrl;
062        }
063
064        /** {@inheritDoc} */
065        @Override
066        public int hashCode() {
067                return Objects.hashCode(adminContactUrl, apiVersion, minSupportedApiVersion);
068        }
069
070        /** {@inheritDoc} */
071        @Override
072        public boolean equals(Object obj) {
073                if (!(obj instanceof ServiceApiInfo)) {
074                        return false;
075                }
076                ServiceApiInfo other = (ServiceApiInfo) obj;
077                if (!Objects.equal(adminContactUrl, other.adminContactUrl)) {
078                        return false;
079                }
080                if (!Objects.equal(apiVersion, other.apiVersion)) {
081                        return false;
082                }
083                if (!Objects.equal(minSupportedApiVersion, other.minSupportedApiVersion)) {
084                        return false;
085                }
086                return true;
087        }
088
089        /** {@inheritDoc} */
090        @Override
091        public String toString() {
092                return "ServiceApiInfo [apiVersion=" + apiVersion + ", minSupportedApiVersion=" + minSupportedApiVersion
093                                + ", adminContactUrl=" + adminContactUrl + "]";
094        }
095
096}