Example usage for org.apache.commons.jxpath.util TypeUtils canConvert

List of usage examples for org.apache.commons.jxpath.util TypeUtils canConvert

Introduction

In this page you can find the example usage for org.apache.commons.jxpath.util TypeUtils canConvert.

Prototype

public static boolean canConvert(Object object, Class toType) 

Source Link

Document

Returns true if the global converter can convert the supplied object to the specified type.

Usage

From source file:org.xchain.framework.jxpath.MethodLookupUtils.java

/**
 * Return a match code between an object and type.
 * @param expected class to test/*from   w w  w  .  j  ava 2s . c om*/
 * @param object object to test
 * @return int code
 */
private static int matchType(Class expected, Object object) {
    if (object == null) {
        return APPROXIMATE_MATCH;
    }

    Class actual = object.getClass();

    if (expected.equals(actual)) {
        return EXACT_MATCH;
    }
    if (expected.isAssignableFrom(actual)) {
        return EXACT_MATCH;
    }

    if (TypeUtils.canConvert(object, expected)) {
        return APPROXIMATE_MATCH;
    }

    return NO_MATCH;
}