Class APIResource<T extends APIEntity>


  • public class APIResource<T extends APIEntity>
    extends java.lang.Object
    Author:
    Ɓukasz Kajda
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected APIClient client  
      protected java.lang.String resourceURI  
      protected java.lang.Class<T> type  
    • Constructor Summary

      Constructors 
      Constructor Description
      APIResource​(APIClient client, java.lang.String resourceURI, java.lang.Class<T> type)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete()
      Deletes the entity owned by this resource in server side.
      T getEntity()
      Returns the entity owned by this resource.
      java.io.InputStream getStream()
      Calls API and returns response stream as a result.
      void refresh()
      Forces retrieving entity from the server side.
      T update()
      Updates the entity owned by this resource in server side.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • type

        protected final java.lang.Class<T extends APIEntity> type
      • resourceURI

        protected final java.lang.String resourceURI
    • Constructor Detail

      • APIResource

        public APIResource​(APIClient client,
                           java.lang.String resourceURI,
                           java.lang.Class<T> type)
    • Method Detail

      • getEntity

        public T getEntity()
                    throws APIException
        Returns the entity owned by this resource. It may be retrieved from server or from cache.
        Throws:
        APIException - on any API errors.
      • getStream

        public java.io.InputStream getStream()
                                      throws APIException
        Calls API and returns response stream as a result. No cache is used here.
        Returns:
        InputStream from API response
        Throws:
        APIException - on any API errors.
      • update

        public T update()
                 throws APIException
        Updates the entity owned by this resource in server side.
        Returns:
        updated entity
        Throws:
        APIException - on any API errors.
      • delete

        public void delete()
                    throws APIException
        Deletes the entity owned by this resource in server side.
        Throws:
        APIException - on any API errors.
      • refresh

        public void refresh()
                     throws APIException
        Forces retrieving entity from the server side.
        Throws:
        APIException - on any API errors.