Class KiwiEntities


  • public class KiwiEntities
    extends Object
    Static utilities related to reading entities from a Response.
    • Constructor Detail

      • KiwiEntities

        public KiwiEntities()
    • 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 empty Optional.
        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 given Class specified by entityType. If it cannot be read, return an empty Optional.
        Type Parameters:
        T - the entity type
        Parameters:
        response - the response object
        entityType - 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 given GenericType specified by entityType. If it cannot be read, return an empty Optional.
        Type Parameters:
        T - the entity type
        Parameters:
        response - the response object
        entityType - 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