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

com.cloudconvert.resource.params.converter.PaginationToNameValuePairsConverter Maven / Gradle / Ivy

Go to download

CloudConvert is an online file converter API - more than 200 different audio, video, document, ebook, archive, image, spreadsheet and presentation formats supported.

There is a newer version: 1.2.1
Show newest version
package com.cloudconvert.resource.params.converter;

import com.cloudconvert.resource.params.Pagination;
import com.google.common.collect.ImmutableList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Optional;

public class PaginationToNameValuePairsConverter implements Converter> {

    private static final String PARAMETER_PER_PAGE = "per_page";
    private static final String PARAMETER_PAGE = "page";

    @Override
    public List convert(@Nullable final Pagination pagination) {
        return Optional.ofNullable(pagination)
            .map(paginationNotNull -> ImmutableList.of(
                new BasicNameValuePair(PARAMETER_PER_PAGE, String.valueOf(paginationNotNull.getPerPage())),
                new BasicNameValuePair(PARAMETER_PAGE, String.valueOf(paginationNotNull.getPage()))
            )).orElse(ImmutableList.of());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy