driver-legacy/src/main/com/mongodb/Bytes.java
@SuppressWarnings("deprecation")
    public static byte getType(final Object object) {
        if (object == null) {
            return NULL;
        }

        if (object instanceof Integer
            || object instanceof Short
            || object instanceof Byte
            || object instanceof AtomicInteger) {
            return NUMBER_INT;
        }

        if (object instanceof Long || object instanceof AtomicLong) {
            return NUMBER_LONG;
        }

        if (object instanceof Number) {
            return NUMBER;
        }

        if (object instanceof String) {
            return STRING;
        }

        if (object instanceof java.util.List) {
            return ARRAY;
        }

        if (object instanceof byte[]) {
            return BINARY;
        }

        if (object instanceof ObjectId) {
            return OID;
        }

        if (object instanceof Boolean) {
            return BOOLEAN;
        }

        if (object instanceof java.util.Date) {
            return DATE;
        }

        if (object instanceof BSONTimestamp) {
            return TIMESTAMP;
        }

        if (object instanceof java.util.regex.Pattern) {
            return REGEX;
        }

        if (object instanceof DBObject || object instanceof DBRef) {
            return OBJECT;
        }

        if (object instanceof CodeWScope) {
            return CODE_W_SCOPE;
        }

        if (object instanceof Code) {
            return CODE;
        }

        return -1;
    }
@SuppressWarnings("deprecation")
    public static byte getType(final Object object) {
        if (object == null) {
            return NULL;
        }

        if (object instanceof Integer
            || object instanceof Short
            || object instanceof Byte
            || object instanceof AtomicInteger) {
            return NUMBER_INT;
        }

        if (object instanceof Long || object instanceof AtomicLong) {
            return NUMBER_LONG;
        }

        if (object instanceof Number) {
            return NUMBER;
        }

        if (object instanceof String) {
            return STRING;
        }

        if (object instanceof java.util.List) {
            return ARRAY;
        }

        if (object instanceof byte[]) {
            return BINARY;
        }

        if (object instanceof ObjectId) {
            return OID;
        }

        if (object instanceof Boolean) {
            return BOOLEAN;
        }

        if (object instanceof java.util.Date) {
            return DATE;
        }

        if (object instanceof BSONTimestamp) {
            return TIMESTAMP;
        }

        if (object instanceof java.util.regex.Pattern) {
            return REGEX;
        }

        if (object instanceof DBObject || object instanceof DBRef) {
            return OBJECT;
        }

        if (object instanceof CodeWScope) {
            return CODE_W_SCOPE;
        }

        if (object instanceof Code) {
            return CODE;
        }

        return -1;
    }
@ SuppressWarnings ( "deprecation" ) public static byte getType ( final Object object ) { if ( object == null ) { return NULL ; } if ( object instanceof Integer || object instanceof Short || object instanceof Byte || object instanceof AtomicInteger ) { return NUMBER_INT ; } if ( object instanceof Long || object instanceof AtomicLong ) { return NUMBER_LONG ; } if ( object instanceof Number ) { return NUMBER ; } if ( object instanceof String ) { return STRING ; } if ( object instanceof java . util . List ) { return ARRAY ; } if ( object instanceof byte [ ] ) { return BINARY ; } if ( object instanceof ObjectId ) { return OID ; } if ( object instanceof Boolean ) { return BOOLEAN ; } if ( object instanceof java . util . Date ) { return DATE ; } if ( object instanceof BSONTimestamp ) { return TIMESTAMP ; } if ( object instanceof java . util . regex . Pattern ) { return REGEX ; } if ( object instanceof DBObject || object instanceof DBRef ) { return OBJECT ; } if ( object instanceof CodeWScope ) { return CODE_W_SCOPE ; } if ( object instanceof Code ) { return CODE ; } return - 1 ; }
Gets the type byte for a given object.

@param object the object
@return the byte value associated with the type, or -1 if no type is matched
Gets the type byte for a given object .