Java tutorial
/* * Copyright (c) 2014 Andrey Paslavsky. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.paslavsky.springrest; import org.springframework.http.HttpMethod; import org.springframework.util.ObjectUtils; import java.util.Map; /** * This class collect metadata that needed to invoke REST web-service * * @author Andrey Paslavsky * @version 1.0 */ public final class RestMethodMetadata { private String commonPath; private String additionalPath; private HttpMethod httpMethod; private Class<?> responseClass; private Class<?> methodReturnType; private Map<String, Integer> uriVarParameters; private Integer requestParameter; private Map<String, Integer> requestHeaderParameters; private Map<String, Integer> queryParameters; public String getCommonPath() { return commonPath; } public void setCommonPath(String commonPath) { this.commonPath = commonPath; } public HttpMethod getHttpMethod() { return httpMethod; } public void setHttpMethod(HttpMethod httpMethod) { this.httpMethod = httpMethod; } public Class<?> getResponseClass() { return responseClass; } public void setResponseClass(Class<?> responseClass) { this.responseClass = responseClass; } public Class<?> getMethodReturnType() { return methodReturnType; } public void setMethodReturnType(Class<?> methodReturnType) { this.methodReturnType = methodReturnType; } public Map<String, Integer> getUriVarParameters() { return uriVarParameters; } public void setUriVarParameters(Map<String, Integer> uriVarParameters) { this.uriVarParameters = uriVarParameters; } public String getAdditionalPath() { return additionalPath; } public void setAdditionalPath(String additionalPath) { this.additionalPath = additionalPath; } public Integer getRequestParameter() { return requestParameter; } public void setRequestParameter(Integer requestParameter) { this.requestParameter = requestParameter; } public Map<String, Integer> getRequestHeaderParameters() { return requestHeaderParameters; } public void setRequestHeaderParameters(Map<String, Integer> requestHeaderParameters) { this.requestHeaderParameters = requestHeaderParameters; } public Map<String, Integer> getQueryParameters() { return queryParameters; } public void setQueryParameters(Map<String, Integer> queryParameters) { this.queryParameters = queryParameters; } @Override public String toString() { return "RestMethodMetadata{" + "commonPath='" + commonPath + '\'' + ", additionalPath='" + additionalPath + '\'' + ", httpMethod=" + httpMethod + ", responseClass=" + responseClass + ", methodReturnType=" + methodReturnType + ", uriVarParameters=" + uriVarParameters + ", requestParameter=" + requestParameter + ", requestHeaderParameters=" + requestHeaderParameters + ", queryParameters=" + queryParameters + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; RestMethodMetadata metadata = (RestMethodMetadata) o; return ObjectUtils.nullSafeEquals(additionalPath, metadata.additionalPath) && ObjectUtils.nullSafeEquals(commonPath, metadata.commonPath) && httpMethod == metadata.httpMethod && methodReturnType == metadata.methodReturnType && ObjectUtils.nullSafeEquals(queryParameters, metadata.queryParameters) && ObjectUtils.nullSafeEquals(requestHeaderParameters, metadata.requestHeaderParameters) && ObjectUtils.nullSafeEquals(requestParameter, metadata.requestParameter) && responseClass == metadata.responseClass && ObjectUtils.nullSafeEquals(uriVarParameters, metadata.uriVarParameters); } @Override public int hashCode() { int result = commonPath != null ? commonPath.hashCode() : 0; result = 31 * result + (additionalPath != null ? additionalPath.hashCode() : 0); result = 31 * result + (httpMethod != null ? httpMethod.hashCode() : 0); return result; } }