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 java.lang.reflect.*; 018 019import org.apache.juneau.*; 020import org.apache.juneau.http.annotation.*; 021import org.apache.juneau.httppart.bean.*; 022 023/** 024 * Represents the metadata about the returned object of a method on a remote proxy interface. 025 * 026 * <h5 class='section'>See Also:</h5> 027 * <ul class='doctree'> 028 * <li class='link'>{@doc juneau-rest-client.RestProxies} 029 * </ul> 030 */ 031public final class RemoteMethodReturn { 032 033 private final Type returnType; 034 private final RemoteReturn returnValue; 035 private final ResponseBeanMeta meta; 036 037 RemoteMethodReturn(Method m) { 038 RemoteMethod rm = m.getAnnotation(RemoteMethod.class); 039 Class<?> rt = m.getReturnType(); 040 RemoteReturn rv = rt == void.class ? RemoteReturn.NONE : rm == null ? RemoteReturn.BODY : rm.returns(); 041 if (hasAnnotation(Response.class, rt) && rt.isInterface()) { 042 this.meta = ResponseBeanMeta.create(m, PropertyStore.DEFAULT); 043 rv = RemoteReturn.BEAN; 044 } else { 045 this.meta = null; 046 } 047 this.returnType = m.getGenericReturnType(); 048 this.returnValue = rv; 049 } 050 051 /** 052 * Returns schema information about the HTTP part. 053 * 054 * @return Schema information about the HTTP part, or <jk>null</jk> if not found. 055 */ 056 public ResponseBeanMeta getResponseBeanMeta() { 057 return meta; 058 } 059 060 /** 061 * Returns the class type of the method return. 062 * 063 * @return The class type of the method return. 064 */ 065 public Type getReturnType() { 066 return returnType; 067 } 068 069 /** 070 * Specifies whether the return value is the body of the request or the HTTP status. 071 * 072 * @return The type of value returned. 073 */ 074 public RemoteReturn getReturnValue() { 075 return returnValue; 076 } 077}