<T> RetrievalRequest<T> internalGet( @Nonnull Class<T> resource, @Nonnull Identifier identifier ) { checkNotNull( resource ); checkNotNull( identifier, Identifier.class.getSimpleName() + " for GET operation cannot be null." ); GetExecutorAdaptee adaptee = adaptee( GetExecutorAdaptee.class, resource ); Object remoteRequest; try { //noinspection unchecked remoteRequest = adaptee.prepareGet( identifier ); } catch ( IOException e ) { throw new ClientErrorException( e.getMessage() ); } return new GetRequest<>( resource, identifier.root(), this, adaptee, remoteRequest ); }
@Override public <T> ListRequest<T> list( @Nonnull Class<T> resource, @Nullable Identifier parent ) { checkNotNull( resource ); ListExecutorAdaptee adaptee = adaptee( ListExecutorAdaptee.class, resource ); Object remoteRequest; try { //noinspection unchecked remoteRequest = adaptee.prepareList( parent == null ? null : parent.root() ); } catch ( IOException e ) { throw new ClientErrorException( e.getMessage() ); } return new ListRequest<>( resource, this, adaptee, remoteRequest ); }
@SuppressWarnings( "unchecked" ) <T> PayloadRequest<T> internalDelete( @Nonnull Class<T> resource, @Nonnull Identifier identifier ) { checkNotNull( resource ); checkNotNull( identifier ); DeleteExecutorAdaptee adaptee = adaptee( DeleteExecutorAdaptee.class, resource ); Object remoteRequest; try { remoteRequest = adaptee.prepareDelete( identifier.root() ); } catch ( IOException e ) { throw new ClientErrorException( e.getMessage() ); } // by default response type is not being provided (resulting in null), client can configure if expected return new DeleteRequest( identifier, this, adaptee, remoteRequest ); }
try remoteRequest = adaptee.prepareUpdate( source, identifier.root(), provider );
<T> PayloadRequest<T> internalInsert( @Nonnull T resource, @Nullable Identifier parentKey, @Nullable MediaProvider provider ) { checkNotNull( resource ); Class<?> remoteResource = evaluateRemoteResource( resource.getClass() ); Object source; if ( resource.getClass() == remoteResource ) { source = resource; } else { source = mapper.map( resource, remoteResource ); } @SuppressWarnings( "unchecked" ) InsertExecutorAdaptee<Object> adaptee = adaptee( InsertExecutorAdaptee.class, resource.getClass() ); Object remoteRequest; try { remoteRequest = adaptee.prepareInsert( source, parentKey == null ? null : parentKey.root(), provider ); } catch ( IOException e ) { throw new ClientErrorException( e.getMessage() ); } @SuppressWarnings( "unchecked" ) Class<T> resourceClass = ( Class<T> ) resource.getClass(); return new InsertRequest<>( resourceClass, parentKey, this, adaptee, remoteRequest ); }
String type = headers == null ? null : headers.getContentType(); URL path = adaptee.prepareDownloadUrl( identifier.root(), type, params, locale ); if ( path == null )
Identifier root = identifier.root(); return new DownloadRequestImpl( this, adaptee, downloader, resource, root, output, interceptor, type );