Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.robrua.orianna.api;
 
 import java.util.List;
 
 public abstract class Utils {
    
Breaks a list of IDs into smaller lists under the limited size

Parameters:
<T> the type of the IDs
IDs the IDs to split
limit the list size limit
Returns:
the split lists
    public static <T> List<List<T>> breakUpList(final List<T> IDsfinal int limit) {
        final List<List<T>> result = new ArrayList<>(IDs.size() / limit + 1);
        List<T> list = new ArrayList<>();
        for(int i = 0; i < IDs.size(); i++) {
            if(i % limit == 0 && i != 0) {
                result.add(list);
                list = new ArrayList<>();
            }
            list.add(IDs.get(i));
        }
        result.add(list);
        return result;
    }

    
Converts an array of longs into a list

Parameters:
vals the values to convert
Returns:
the result list
    public static List<Longconvert(final long... vals) {
        final List<Longvalues = new ArrayList<>(vals.length);
        for(final long val : vals) {
            values.add(val);
        }
        return values;
    }

    
Stringifies a list of IDs

Parameters:
<T> the type of the IDs
IDs the IDs
Returns:
a string of the IDs
    public static <T> String getIDString(final List<T> IDs) {
        final StringBuilder sb = new StringBuilder();
        for(final T ID : IDs) {
            sb.append("," + ID.toString());
        }
        return sb.substring(1);
    }
New to GrepCode? Check out our FAQ X