/** * Posts a collection of typed objects * @param collection request body * @param memberClass type of collection member class * @return JAX-RS Response */ public <T> Response postCollection(Object collection, Class<T> memberClass) { return doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType(memberClass), Response.class, Response.class); }
/** * Posts a collection of typed objects * @param collection request body * @param memberClass type of collection member class * @return JAX-RS Response */ public <T> Response postCollection(Object collection, Class<T> memberClass) { return doInvoke("POST", collection, new ParameterizedCollectionType(memberClass), Response.class, Response.class); }
/** * Posts a collection of typed objects * @param collection request body * @param memberClass type of collection member class * @return JAX-RS Response */ public <T> Response postCollection(Object collection, Class<T> memberClass) { return doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType(memberClass), Response.class, Response.class); }
/** * Posts collection of typed objects and returns a collection of typed objects * @param collection request body * @param memberClass type of collection member class * @param responseClass expected type of response object * @return JAX-RS Response */ public <T1, T2> Collection<? extends T2> postAndGetCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass) { Response r = doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType(memberClass), Collection.class, new ParameterizedCollectionType(responseClass)); return CastUtils.cast((Collection<?>)r.getEntity(), responseClass); }
/** * Posts a collection of typed objects * @param collection request body * @param memberClass type of collection member class * @param responseClass expected type of response object * @return JAX-RS Response */ public <T1, T2> T2 postCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass) { Response r = doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType(memberClass), responseClass, responseClass); return responseClass.cast(responseClass == Response.class ? r : r.getEntity()); }
/** * Posts a collection of typed objects * @param collection request body * @param memberClass type of collection member class * @param responseClass expected type of response object * @return JAX-RS Response */ public <T1, T2> T2 postCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass) { Response r = doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType(memberClass), responseClass, responseClass); return responseClass.cast(responseClass == Response.class ? r : r.getEntity()); }
/** * Posts a collection of typed objects * @param collection request body * @param memberClass type of collection member class * @param responseClass expected type of response object * @return JAX-RS Response */ public <T1, T2> T2 postCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass) { Response r = doInvoke("POST", collection, new ParameterizedCollectionType(memberClass), responseClass, responseClass); return responseClass.cast(responseClass == Response.class ? r : r.getEntity()); }
/** * Posts collection of typed objects and returns a collection of typed objects * @param collection request body * @param memberClass type of collection member class * @param responseClass expected type of response object * @return JAX-RS Response */ public <T1, T2> Collection<? extends T2> postAndGetCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass) { Response r = doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType(memberClass), Collection.class, new ParameterizedCollectionType(responseClass)); return CastUtils.cast((Collection<?>)r.getEntity(), responseClass); }
/** * Posts collection of typed objects and returns a collection of typed objects * @param collection request body * @param memberClass type of collection member class * @param responseClass expected type of response object * @return JAX-RS Response */ public <T1, T2> Collection<? extends T2> postAndGetCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass) { Response r = doInvoke("POST", collection, new ParameterizedCollectionType(memberClass), Collection.class, new ParameterizedCollectionType(responseClass)); return CastUtils.cast((Collection<?>)r.getEntity(), responseClass); }
/** * Does HTTP invocation and returns a collection of typed objects * @param httpMethod HTTP method * @param body request body, can be null * @param memberClass expected type of collection member class * @return typed collection */ public <T> Collection<? extends T> invokeAndGetCollection(String httpMethod, Object body, Class<T> memberClass) { Response r = doInvoke(httpMethod, body, null, Collection.class, new ParameterizedCollectionType(memberClass)); return CastUtils.cast((Collection<?>)r.getEntity(), memberClass); }
/** * Does HTTP invocation and returns a collection of typed objects * @param httpMethod HTTP method * @param body request body, can be null * @param memberClass expected type of collection member class * @return typed collection */ public <T> Collection<? extends T> invokeAndGetCollection(String httpMethod, Object body, Class<T> memberClass) { Response r = doInvoke(httpMethod, body, null, Collection.class, new ParameterizedCollectionType(memberClass)); return CastUtils.cast((Collection<?>)r.getEntity(), memberClass); }
/** * Does HTTP invocation and returns a collection of typed objects * @param httpMethod HTTP method * @param body request body, can be null * @param memberClass expected type of collection member class * @return typed collection */ public <T> Collection<? extends T> invokeAndGetCollection(String httpMethod, Object body, Class<T> memberClass) { Response r = doInvoke(httpMethod, body, null, Collection.class, new ParameterizedCollectionType(memberClass)); return CastUtils.cast((Collection<?>)r.getEntity(), memberClass); }
/** * Posts the object and returns a collection of typed objects * @param body request body * @param responseClass expected type of response object * @return JAX-RS Response */ public <T> Collection<? extends T> postObjectGetCollection(Object body, Class<T> responseClass) { Response r = doInvoke(HttpMethod.POST, body, null, Collection.class, new ParameterizedCollectionType(responseClass)); return CastUtils.cast((Collection<?>)r.getEntity(), responseClass); }
/** * Posts the object and returns a collection of typed objects * @param body request body * @param responseClass expected type of response object * @return JAX-RS Response */ public <T> Collection<? extends T> postObjectGetCollection(Object body, Class<T> responseClass) { Response r = doInvoke(HttpMethod.POST, body, null, Collection.class, new ParameterizedCollectionType(responseClass)); return CastUtils.cast((Collection<?>)r.getEntity(), responseClass); }
/** * Posts the object and returns a collection of typed objects * @param body request body * @param memberClass type of collection member class * @param responseClass expected type of response object * @return JAX-RS Response */ public <T> Collection<? extends T> postObjectGetCollection(Object body, Class<T> responseClass) { Response r = doInvoke("POST", body, null, Collection.class, new ParameterizedCollectionType(responseClass)); return CastUtils.cast((Collection<?>)r.getEntity(), responseClass); }
public static Type processGenericTypeIfNeeded(Class<?> serviceCls, Class<?> paramCls, Type type) { if (type instanceof TypeVariable) { type = InjectionUtils.getSuperType(serviceCls, (TypeVariable<?>)type); } else if (type instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)type; if (pt.getActualTypeArguments()[0] instanceof TypeVariable && isSupportedCollectionOrArray(getRawType(pt))) { TypeVariable<?> typeVar = (TypeVariable<?>)pt.getActualTypeArguments()[0]; Type theType = InjectionUtils.getSuperType(serviceCls, typeVar); if (theType instanceof Class) { type = new ParameterizedCollectionType((Class<?>)theType); } else { type = processGenericTypeIfNeeded(serviceCls, paramCls, theType); type = new ParameterizedCollectionType(type); } } } if (type == null || type == Object.class) { type = paramCls; } return type; }
public static Type processGenericTypeIfNeeded(Class<?> serviceCls, Class<?> paramCls, Type type) { if (type instanceof TypeVariable) { type = InjectionUtils.getSuperType(serviceCls, (TypeVariable<?>)type); } else if (type instanceof ParameterizedType && ((ParameterizedType)type).getActualTypeArguments()[0] instanceof TypeVariable && isSupportedCollectionOrArray(getRawType(type))) { TypeVariable<?> typeVar = (TypeVariable<?>)((ParameterizedType)type).getActualTypeArguments()[0]; Type theType = InjectionUtils.getSuperType(serviceCls, typeVar); Class<?> cls = theType instanceof Class ? (Class<?>)theType : InjectionUtils.getActualType(theType, 0); type = new ParameterizedCollectionType(cls); } if (type == null || type == Object.class) { type = paramCls; } return type; }