private static String rationalPartFrom(String expression, int part) {
        notNull(expression, "Expression cannot be null");
        int p = expression.indexOf("/");
        switch (part) {
            case NUMERATOR:
                return p > 0 ? expression.substring(0, p) : expression;
            case DENOMINATOR:
                return p > 0 ? expression.substring(p + 1) : "1";
            default:
                throw new IllegalArgumentException("Unknown part type");
        }
    }