001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest;
014
015import java.lang.reflect.*;
016
017/**
018 * @deprecated Unused.
019 */
020@Deprecated
021public abstract class RestParam {
022
023   final RestParamType paramType;
024   final String name;
025   final Type type;
026
027   /**
028    * Constructor.
029    *
030    * @param paramType The Swagger parameter type.
031    * @param name
032    *    The parameter name.
033    *    Can be <jk>null</jk> if parameter doesn't have a name (e.g. the request body).
034    * @param type The object type to convert the parameter to.
035    */
036   protected RestParam(RestParamType paramType, String name, Type type) {
037      this.paramType = paramType;
038      this.name = name;
039      this.type = type;
040   }
041
042   /**
043    * Resolves the parameter object.
044    *
045    * @param req The rest request.
046    * @param res The rest response.
047    * @return The resolved object.
048    * @throws Exception
049    */
050   public abstract Object resolve(RestRequest req, RestResponse res) throws Exception;
051
052   /**
053    * Returns the parameter class type that this parameter resolver is meant for.
054    *
055    * @return The parameter class type, or <jk>null</jk> if the type passed in isn't an instance of {@link Class}.
056    */
057   protected Class<?> forClass() {
058      if (type instanceof Class)
059         return (Class<?>)type;
060      return null;
061   }
062
063   /**
064    * Returns the swagger parameter type for this parameter as shown in the Swagger doc.
065    *
066    * @return the swagger parameter type for this parameter.
067    */
068   protected RestParamType getParamType() {
069      return paramType;
070   }
071
072   /**
073    * Returns the parameter name for this parameter as shown in the Swagger doc.
074    *
075    * @return the parameter name for this parameter.
076    */
077   protected String getName() {
078      return name;
079   }
080
081   /**
082    * Returns the parameter class type.
083    *
084    * @return the parameter class type.
085    */
086   public Type getType() {
087      return type;
088   }
089}