Home | History | Annotate | Download | only in util
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.android.tv.tuner.util;
     17 
     18 import java.util.ArrayList;
     19 import java.util.List;
     20 
     21 /** Static utility methods pertaining to int primitives. (Referred Guava's Ints class) */
     22 public class Ints {
     23     private Ints() {}
     24 
     25     public static int[] toArray(List<Integer> integerList) {
     26         int[] intArray = new int[integerList.size()];
     27         int i = 0;
     28         for (Integer data : integerList) {
     29             intArray[i++] = data;
     30         }
     31         return intArray;
     32     }
     33 
     34     public static List<Integer> asList(int[] intArray) {
     35         List<Integer> integerList = new ArrayList<>(intArray.length);
     36         for (int data : intArray) {
     37             integerList.add(data);
     38         }
     39         return integerList;
     40     }
     41 }
     42