driver-core/src/main/com/mongodb/client/model/Filters.java
public static Bson type(final String fieldName, final BsonType type) {
        return new OperatorFilter<BsonInt32>("$type", fieldName, new BsonInt32(type.getValue()));
    }
public static Bson type(final String fieldName, final BsonType type) {
        return new OperatorFilter<BsonInt32>("$type", fieldName, new BsonInt32(type.getValue()));
    }
Creates a filter that matches all documents where the value of the field is of the specified BSON type.

@param fieldName the field name
@param type      the BSON type
@return the filter
@mongodb.driver.manual reference/operator/query/type $type