protected function buildJoins()
    {
        $builtJoins = [];
        foreach ($this->joins as $type => $joins) {
            if (count($joins) > 0) {
                foreach ($joins as $join) {
                    if ($type === self::JOIN_INNER) {
                        $builtJoins[] = 'INNER JOIN';
                    } elseif ($type === self::JOIN_LEFT) {
                        $builtJoins[] = 'LEFT JOIN';
                    } elseif ($type === self::JOIN_RIGHT) {
                        $builtJoins[] = 'RIGHT JOIN';
                    } elseif ($type === self::JOIN_FULL) {
                        $builtJoins[] = 'FULL JOIN';
                    }

                    $builtJoins[] = $this->quoteIdentifier($join->getJoinTableName()) . ' ON';

                    // Use a ConditionSet to build the joins
                    $conditionSet = new Query\Condition\AndSet($this, [$join]);
                    $builtJoins[] = $conditionSet->buildWithoutParentheses();
                }
            }
        }

        return implode(' ', $builtJoins);
    }