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

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

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

import java.lang.reflect.Type;

public class CharConverter implements Converter {

    public final static CharConverter instance = new CharConverter();

    public Character convertTo(Object obj, Type type) {
        if (obj instanceof String) {
            return ((String) obj).charAt(0);
        }
        else if (obj instanceof char[]) {
            return ((char[]) obj)[0];
        }
        return (Character) obj;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy