예제 #1
0
 public static int toInt(final Object o) {
   if (o instanceof BigDecimal) {
     return NumberUtil.toInt((BigDecimal) o);
   } else if (o instanceof Number) {
     return new BigDecimal(String.valueOf(o)).intValue();
   } else {
     return NumberUtils.toInt(String.valueOf(o));
   }
 }
예제 #2
0
 /** Tranforma um array de Object em um array de Números inteiros. */
 public static int[] toIntArray(final Object[] strArray) {
   if (strArray == null) {
     return new int[0];
   }
   final int[] numeros = new int[strArray.length];
   for (int i = 0; i < strArray.length; i++) {
     numeros[i] = NumberUtil.toInt(strArray[i]);
   }
   return numeros;
 }
예제 #3
0
 /** Tranforma um array de Object em um array de Números inteiros. */
 public static Set<Integer> toIntegerSet(final Object[] strArray) {
   if (strArray == null) {
     return new HashSet<Integer>(0);
   } else {
     final Set<Integer> numeros = new HashSet<Integer>();
     for (final Object element : strArray) {
       numeros.add(NumberUtil.toInt(element));
     }
     return numeros;
   }
 }