class QueryToMongodb {

    public static Bson getCommand(final Query query)
        throws InvalidParseOperationException {
        final QUERY req = query.getQUERY();
        final JsonNode content = query.getNode(req.exactToken());
        switch (req) {
            case AND:
            case NOT:
            case OR:
                return booleanCommand(query, req);
            case EXISTS:
            case MISSING:
                return exists(content.asText(), req == QUERY.EXISTS);
            case FLT:
            case MLT:
            case MATCH:
            case MATCH_ALL:
            case MATCH_PHRASE:
            case MATCH_PHRASE_PREFIX:
            case SEARCH:
            case SUBOBJECT:
                throw new InvalidParseOperationException(
                    COMMAND_NOT_ALLOWED_WITH_MONGO_DB + req.exactToken());
            case NIN:
            case IN:
                return inCommand(req, content);
            case RANGE:
                return rangeCommand(req, content);
            case REGEX:
                return regexCommand(req, content);
            case TERM:
                return termCommand(content);
            case WILDCARD:
                return wildcardCommand(req, content);
            case EQ:
            case GT:
            case GTE:
            case LT:
            case LTE:
            case NE:
                return comparatorCommand(req, content);
            case ISNULL:
                return isNullCommand(content);
            case SIZE:
                return sizeCommand(req, content);
            case GEOMETRY:
            case BOX:
            case POLYGON:
            case CENTER:
            case GEOINTERSECTS:
            case GEOWITHIN:
            case PATH:
                return pathCommand(content);
            case NOP:
                return new BasicDBObject();
            default:
        }
        throw new InvalidParseOperationException("Invalid command: " + req.exactToken());
    }

    private  QueryToMongodb();

}