Java Object to int castToInteger(Object object)

Here you can find the source of castToInteger(Object object)

Description

Sometimes ELP's version of cast is misbehaving

License

GNU General Public License

Parameter

Parameter Description
object a parameter

Declaration

public static Integer castToInteger(Object object) 

Method Source Code

//package com.java2s;
/*//w w  w . j  av  a  2 s  . 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 {
    /**
     * Sometimes ELP's version of cast is misbehaving
     * 
     * @param object
     * @return
     */
    public static Integer castToInteger(Object object) {
        if (object != null) {
            if (object instanceof Integer)
                return (Integer) object;
            else
                return Integer.valueOf(object.toString());
        }
        return null;
    }
}

Related

  1. castInt(Object o)
  2. castToInt(double[] aDouble)
  3. castToInt(final long value)
  4. castToInt(Object value)
  5. castToInteger(final String uid)
  6. castToInteger(Object value)
  7. castToIntegerArray(Object[] array)
  8. castToInts(final double[] doubles)
  9. objToInt(Object obj)