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.client.remote;
014
015import static org.apache.juneau.internal.ClassUtils.*;
016
017import org.apache.juneau.http.annotation.*;
018import org.apache.juneau.httppart.*;
019import org.apache.juneau.httppart.bean.*;
020
021/**
022 * Represents the metadata about an {@link Request}-annotated argument of a method on a REST proxy class.
023 *
024 * <ul class='seealso'>
025 *    <li class='link'>{@doc juneau-rest-client.RestProxies}
026 * </ul>
027 */
028public final class RemoteMethodBeanArg {
029
030   private final int index;
031   private final RequestBeanMeta meta;
032   private final HttpPartSerializer serializer;
033
034   RemoteMethodBeanArg(int index, Class<? extends HttpPartSerializer> serializer, RequestBeanMeta meta) {
035      this.index = index;
036      this.serializer = castOrCreate(HttpPartSerializer.class, serializer);
037      this.meta = meta;
038   }
039
040   /**
041    * Returns the index of the parameter in the method that is a request bean.
042    *
043    * @return The index of the parameter in the method that is a request bean.
044    */
045   public int getIndex() {
046      return index;
047   }
048
049   /**
050    * Returns the serializer to use for serializing parts on the request bean.
051    *
052    * @return The serializer to use for serializing parts on the request bean, or <jk>null</jk> if not defined.
053    */
054   public HttpPartSerializer getSerializer() {
055      return serializer;
056   }
057
058   /**
059    * Returns metadata on the request bean.
060    *
061    * @return Metadata about the bean.
062    */
063   public RequestBeanMeta getMeta() {
064      return meta;
065   }
066}