All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hprose.io.convert.IntConverter Maven / Gradle / Ivy

/**********************************************************\
|                                                          |
|                          hprose                          |
|                                                          |
| Official WebSite: http://www.hprose.com/                 |
|                   http://www.hprose.org/                 |
|                                                          |
\**********************************************************/
/**********************************************************\
 *                                                        *
 * IntConverter.java                                      *
 *                                                        *
 * IntConverter interface for Java.                       *
 *                                                        *
 * LastModified: Aug 3, 2016                              *
 * Author: Ma Bingyao                   *
 *                                                        *
\**********************************************************/
package hprose.io.convert;

import java.lang.reflect.Type;

public class IntConverter implements Converter {

    public final static IntConverter instance = new IntConverter();

    public Integer convertTo(Object obj, Type type) {
        if (obj instanceof String) {
            return Integer.parseInt((String) obj);
        }
        else if (obj instanceof char[]) {
            return Integer.parseInt(new String((char[]) obj));
        }
        return (Integer) obj;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy