Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

import com.google.common.primitives.Ints;

public class Main {
    public static <T> List<T> sublist(List<T> result, long startIndex, long size) {
        long endIndex = result.size();
        if (size < endIndex - startIndex) {
            endIndex = startIndex + size;
        }
        if (startIndex > Integer.MAX_VALUE) {
            throw new RuntimeException("StartIndex " + startIndex
                    + " is bigger than maxInt. You shouldn't use a InMemoryRawMessagingDao.");
        }
        if (endIndex > Integer.MAX_VALUE) {
            throw new RuntimeException("EndIndex " + endIndex
                    + " is bigger than maxInt. You shouldn't use a InMemoryRawMessagingDao.");
        }
        return result.subList(Ints.checkedCast(startIndex), Ints.checkedCast(endIndex));
    }

    public static <T> List<T> sublist(Collection<T> values, long startIndex, long size) {
        return sublist(new ArrayList<T>(values), startIndex, size);
    }
}