All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ctoolkit.restapi.client.ListRetrievalRequest Maven / Gradle / Ivy

Go to download

Fluent facade API to allow perform REST operations of various APIs through a single interface.

The newest version!
/*
 * Copyright (c) 2017 Comvai, s.r.o. All Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

package org.ctoolkit.restapi.client;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;

/**
 * The extended {@link Request} to provide retrieval specific API to work with list of resources.
 *
 * @param  the list item resource type
 * @author Aurel Medvegy
 */
public interface ListRetrievalRequest
        extends RetrievalRequest>
{
    /**
     * Execute a remote call to find the list of resources of given type.
     *
     * @return the list of resources
     */
    @Override
    List finish();

    /**
     * Execute a remote call to find the list of resources of given type
     * with request specific credential and configuration.
     * 

* Note: The underlying API must support (at least partially) this functionality * otherwise these properties will be ignored and default value of target API will be used. * * @param credential the credential and configuration to be applied to this request * @return the resource as a result of the remote call */ @Override List finish( @Nonnull RequestCredential credential ); /** * Execute a remote call to find filtered list of resources. * * @param start the position of the first result, numbered from 0 * @param length the maximum number of results to retrieve * @return the list of filtered resources, if none returns empty list * @throws IllegalArgumentException thrown for any negative numbers */ List finish( int start, int length ); /** * Execute a remote call to find the list of resources of given type and additional filtering criteria. * * @param criteria the optional filtering criteria map * @return the list of resources matching filtering criteria, otherwise returns empty list */ @Override List finish( @Nullable Map criteria ); /** * Execute a remote call to find the list of resources with specified locale. * * @param locale the language the client has configured to prefer in results if applicable * @return the resource as a result of the remote call */ @Override List finish( @Nullable Locale locale ); /** * Execute a remote call to find the list of resources of given type and additional filtering criteria. * o * * @param criteria the optional filtering criteria map * @param locale the language the client has configured to prefer in results if applicable * @return the list of resources matching filtering criteria, otherwise returns empty list */ @Override List finish( @Nullable Map criteria, @Nullable Locale locale ); /** * Apply specific properties as request configuration to this call. * * @param properties the properties and configuration to be applied to this request * @return this request to chain calls * @see #finish(Map) */ @Override ListRetrievalRequest configWith( @Nonnull Properties properties ); /** * Config request with optional locale. * * @param locale the language the client has configured to prefer in results if applicable * @return this request to chain calls */ @Override ListRetrievalRequest forLang( @Nonnull Locale locale ); /** * Set the position of the first result to retrieve. * * @param start the position of the first result, numbered from 0 * @return this request to chain calls * @throws IllegalArgumentException thrown for any negative numbers */ ListRetrievalRequest start( int start ); /** * Set the maximum number of results to retrieve. * * @param length the maximum number of results to retrieve * @return this request to chain calls * @throws IllegalArgumentException thrown for any negative numbers */ ListRetrievalRequest length( int length ); /** * Order the result based on the given property name. * If not set, the underlying API a default value (if any) will be applied. * The underlying API must support sorting functionality, otherwise will be ignored. * * @param property the resource property name used to sort the result * @return this request to chain calls */ ListRetrievalRequest orderBy( @Nullable String property ); /** * Sort the result either ascending or descending for given property by {@link #orderBy(String)}. * If not set, the underlying API a default value (if any) will be applied. * The underlying API must support sorting functionality, otherwise will be ignored. * * @param ascending true to sort the result ascending * @return this request to chain calls */ ListRetrievalRequest sortAscending( boolean ascending ); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy