/*
 * Copyright 2015 Kaiserpfalz EDV-Service, Roland T. Lichti
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package de.kaiserpfalzEdv.vaadin.backend.paging.impl;

import de.kaiserpfalzEdv.vaadin.backend.paging.Pageable;
import de.kaiserpfalzEdv.vaadin.backend.paging.Sorting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author klenkes
 * @version 2015Q1
 * @since 17.09.15 06:44
 */
public class PageableImpl implements Pageable {
    private static final Logger LOG = LoggerFactory.getLogger(PageableImpl.class);

    private long    page;
    private long    size;
    private Sorting sorting;


    public PageableImpl(long page, long size) {
        this.page = page;
        this.size = size;
    }

    public PageableImpl(long page, long size, Sorting sorting) {
        this(page, size);

        this.sorting = sorting;
    }


    @Override
    public long getOffset() {
        return page * size;
    }

    @Override
    public long getEnd() {
        return getOffset() + size;
    }

    @Override
    public long getPage() {
        return page;
    }

    @Override
    public long getPageSize() {
        return size;
    }

    @Override
    public Sorting getSorting() {
        return sorting;
    }
}
