/*
 * Copyright 2018 The twicalico authors
 *
 * 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 com.github.moko256.twicalico.array;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by moko256 on 2018/01/04.
 *
 * @author moko256
 */

public class ArrayUtils {
    @SafeVarargs
    public static <T> List<T> convertToList(T... array){
        return Arrays.asList(array);
    }

    public static List<Long> convertToLongList(long... array){
        List<Long> list = new ArrayList<>(array.length);
        for (long l : array) {
            list.add(l);
        }
        return list;
    }

    @NonNull
    public static CharSequence toCommaSplitString(@Nullable String[] array){
        if (array != null && array.length > 0) {
            StringBuilder builder = new StringBuilder(array.length * 10);
            for (int i = 0; ; i++) {
                builder.append(array[i]);
                if (i < array.length - 1) {
                    builder.append(",");
                } else {
                    return builder;
                }
            }
        } else {
            return "";
        }
    }
}

@@ -920,16 +920,29 @@
 Varargs%0A
+    @NonNull%0A
     publ
@@ -977,16 +977,25 @@
 tToList(
+@NonNull 
 T... arr
@@ -1039,24 +1039,37 @@
 ay);%0A    %7D%0A%0A
+    @NonNull%0A
     public s
@@ -1103,16 +1103,25 @@
 ongList(
+@NonNull 
 long... 

add nullable and nonnull annotation