/** * Add identifier value as child to this parent. * * @param value the long type identifier to be set as child value to this parent * @return the new identifier child instance */ public Identifier addChild( Long value ) { child = new Identifier( value ); return child; }
<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 ); }
@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 ); }
/** * Add identifier value as child to this parent. * * @param value the string type identifier to be set as child value to this parent * @return the new identifier child instance */ public Identifier addChild( String value ) { child = new Identifier( value ); return child; }
@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 ); }
@Override public SingleUploadMediaRequest<T> identifiedBy( @Nonnull String identifier ) { checkNotNull( identifier ); return identifiedBy( new Identifier( identifier ) ); }
try remoteRequest = adaptee.prepareUpdate( source, identifier.root(), provider );
@Override public PayloadRequest<T> identifiedBy( @Nonnull Long identifier ) { return adapter.internalUpdate( resource, new Identifier( identifier ), null ); } }
<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 ); }
@Override public SingleUploadMediaRequest<T> identifiedBy( @Nonnull Long identifier ) { checkNotNull( identifier ); return identifiedBy( new Identifier( identifier ) ); }
@Override public <T> SingleRequest<T> delete( @Nonnull Class<T> resource, @Nonnull Long identifier ) { return delete( resource, new Identifier( identifier ) ); }
String type = headers == null ? null : headers.getContentType(); URL path = adaptee.prepareDownloadUrl( identifier.root(), type, params, locale ); if ( path == null )
@Override public DownloadRequest identifiedBy( @Nonnull String identifier ) { checkNotNull( identifier ); return identifiedBy( new Identifier( identifier ) ); }
Identifier root = identifier.root(); return new DownloadRequestImpl( this, adaptee, downloader, resource, root, output, interceptor, type );
@Override public RetrievalRequest<T> identifiedBy( @Nonnull Long identifier ) { return adapter.internalGet( resource, new Identifier( identifier ) ); } }
@Override public PayloadRequest<T> identifiedBy( @Nonnull String identifier ) { return adapter.internalUpdate( resource, new Identifier( identifier ), null ); }
@Override public PayloadRequest<T> identifiedBy( @Nonnull String identifier ) { return adapter.internalDelete( resource, new Identifier( identifier ) ); }
@Override public <T> SingleRequest<T> get( @Nonnull Class<T> resource, @Nonnull Long identifier ) { return get( resource, new Identifier( identifier ) ); }
@Override public <T> SingleRequest<T> delete( @Nonnull Class<T> resource, @Nonnull String identifier ) { return delete( resource, new Identifier( identifier ) ); }