Package org.kiwiproject.jaxrs
Class KiwiEntities
- java.lang.Object
-
- org.kiwiproject.jaxrs.KiwiEntities
-
public class KiwiEntities extends Object
Static utilities related to reading entities from aResponse.
-
-
Constructor Summary
Constructors Constructor Description KiwiEntities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<String>safeReadEntity(javax.ws.rs.core.Response response)Read an entity as a String from the given response.static <T> Optional<T>safeReadEntity(javax.ws.rs.core.Response response, Class<T> entityType)Read an entity as an instance of the givenClassspecified byentityType.static <T> Optional<T>safeReadEntity(javax.ws.rs.core.Response response, javax.ws.rs.core.GenericType<T> entityType)Read an entity as an instance of the givenGenericTypespecified byentityType.
-
-
-
Method Detail
-
safeReadEntity
public static Optional<String> safeReadEntity(javax.ws.rs.core.Response response)
Read an entity as a String from the given response. If it cannot be read, return an emptyOptional.- Parameters:
response- the response object- Returns:
- an Optional that contains the response as a String or an empty Optional
-
safeReadEntity
public static <T> Optional<T> safeReadEntity(javax.ws.rs.core.Response response, Class<T> entityType)
Read an entity as an instance of the givenClassspecified byentityType. If it cannot be read, return an emptyOptional.- Type Parameters:
T- the entity type- Parameters:
response- the response objectentityType- the type of entity the response is expected to contain- Returns:
- an Optional that contains the response as a specific type or an empty Optional
-
safeReadEntity
public static <T> Optional<T> safeReadEntity(javax.ws.rs.core.Response response, javax.ws.rs.core.GenericType<T> entityType)
Read an entity as an instance of the givenGenericTypespecified byentityType. If it cannot be read, return an emptyOptional.- Type Parameters:
T- the entity type- Parameters:
response- the response objectentityType- the type of entity the response is expected to contain- Returns:
- an Optional that contains the response as a specific type or an empty Optional
-
-