Java Object to int castToIntegerArray(Object[] array)

Here you can find the source of castToIntegerArray(Object[] array)

Description

EPL has embedded cast method, but it doesn't cover arrays

License

GNU General Public License

Parameter

Parameter Description
array a parameter

Declaration

public static Integer[] castToIntegerArray(Object[] array) 

Method Source Code

//package com.java2s;
/*// ww  w  .ja v a 2s.  c  o  m
 Pulsar
 Copyright (C) 2013-2015 eBay Software Foundation
 Licensed under the GPL v2 license.  See LICENSE for full terms.
 */

public class Main {
    /**
     * EPL has embedded cast method, but it doesn't cover arrays
     * 
     * @param array
     * @return
     */
    public static Integer[] castToIntegerArray(Object[] array) {
        if (array != null) {
            Integer[] retArray = new Integer[array.length];
            int i = 0;
            for (Object element : array) {
                retArray[i] = element == null ? null : (Integer) element;
                i++;
            }
            return retArray;
        }
        return null;
    }
}

Related

  1. castToInt(final long value)
  2. castToInt(Object value)
  3. castToInteger(final String uid)
  4. castToInteger(Object object)
  5. castToInteger(Object value)
  6. castToInts(final double[] doubles)
  7. objToInt(Object obj)
  8. objToInteger(Object obj)