Java List to Int List toIntList(Set members)

Here you can find the source of toIntList(Set members)

Description

to Int List

License

Apache License

Declaration

public static List<Integer> toIntList(Set<String> members) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.Iterator;

import java.util.List;
import java.util.Set;

public class Main {
    public static List<Integer> toIntList(Set<String> members) {
        if (members == null || members.isEmpty()) {
            return null;
        }//from  ww  w .  j av  a2 s .c  o  m
        List<Integer> result = new ArrayList<Integer>();
        Iterator<String> iterator = members.iterator();
        while (iterator.hasNext()) {
            String str = iterator.next();
            Integer newsId = Integer.parseInt(str);
            result.add(newsId);
        }
        return result;
    }

    public static List<Integer> toIntList(List<String> members) {
        if (members == null || members.isEmpty()) {
            return null;
        }
        List<Integer> result = new ArrayList<Integer>();
        Iterator<String> iterator = members.iterator();
        while (iterator.hasNext()) {
            String str = iterator.next();
            if (str == null) {
                result.add(null);
            } else {
                int newsId = Integer.parseInt(str);
                result.add(newsId);
            }
        }
        return result;
    }

    public static boolean isEmpty(List<?> list) {
        if (list == null || list.isEmpty()) {
            return true;
        } else {
            return false;
        }
    }
}

Related

  1. toIntegerList(int[] intArray)
  2. toIntegerList(List strList, boolean failOnException)
  3. toIntegers(final List longs)
  4. toIntegers(List values)
  5. toIntList(List list)
  6. toIntList(String arr, String separator)
  7. toInts(List list)