For the past year, the restaurant industry has struggled as foot traffic has been trending lower. Generally bucking the trend, though, has been the upscale casual-dining segment. Shareholders of The Cheesecake Factory (NASDAQ:CAKE) have been benefactors of that trend over the last year. With continued positive expectations for that segment of hospitality through this year, it's time to dig into the numbers to see if this one's a buy.

CAKE Chart

Data by YCharts.

To dine or not to dine

As the economy continues to plod along at a gently rising pace, restaurant sales have gone south. For the past five quarters, comparable sales for the industry (a combination of foot traffic and ticket size) have been declining. Comparable sales fell 2.4% to end 2016 and 1.6% to start 2017. Foot traffic was the main culprit, down 3.6% in the first quarter this year.

The last time that happened was in 2009 through early 2010, as the U.S. began to emerge from the financial crisis. You can read more about why this is happening, but in any event, it's been an ugly run of numbers for restaurants. However, according to TDn2K, the creme de la creme of the industry is doing OK. Fine dining and upscale casual performed the best and posted the only overall increases to same-store sales in the past two quarters.

Everyone loves dessert

That bodes well for Cheesecake Factory, which lays claim to the founding of the upscale casual dining experience. Not only does the chain operate in the restaurant segment that has managed to buck the trend, but most of its restaurants are also located in its home state of California. According to TDn2K, the state has been the best performing region for restaurants the duration of the current downturn.

The original recipe-style cheesecake, served with a side of whipped cream on a white plate.

Image source: Cheesecake Factory.

During the last earnings report, the company posted its 28th consecutive quarter of comparable same-store sales increases, up 1.1% the last three months of 2016. Revenue and earnings per share were up 8.3% and 23%, respectively.

One key ingredient to the company's success has been its measured approach to new openings. Post-financial crisis, chains have been in a hot hurry breaking ground on new restaurants, with some growing each year in the double digits. Cheesecake Factory has been more conservative. In 2015, 10 new restaurants were added, and in 2016 it was only seven. That represents growth of 5.7% and 3.7%, respectively.

Because of that slow and steady growth, the company is still quite small, sporting 194 locations at the end of 2016. Most of those are the namesake Cheesecake Factory restaurants, but a handful of them are the Grand Lux Cafe European-style dining name mainly operating east of the Mississippi, and one RockSugar, a new Asian-style fine-dining experience the company has been testing.

For a company that tries to differentiate itself by offering a nicer experience, slow growth helps protect the value of the name. While the rest of the industry is by and large cannibalizing itself, Cheesecake Factory is standing out as something special. The plan for 2017 is much the same, with only eight openings including one more RockSugar, and as many as five internationally franchised openings.

The interior of a Cheesecake Factory. The décor is art-deco, dark colors and swirling lights reminiscent of the pre-war era.

Image source: Cheesecake Factory.

Is the stock a buy?

It was a strong year for Cheesecake Factory, and it shows in current stock valuations. Trailing price-to-earnings sits at 23. Management sees earnings coming in 4% to 8.5% higher, mostly because of a 1% to 2% rise in comparable sales. One-year forward price-to-earnings based on midpoint expectations is at 21.6.

One-year price-to-earnings-growth, or PEG, is at 3.5, based on the midpoint of management's expectations for 2017. A PEG of 1.0 is typically viewed as fair value, more than 1.0 being overvalued. The stock has simply outgrown growth expectations at this point.

Is Cheesecake Factory the deal of the decade? Probably not. But that doesn't mean it isn't worth keeping an eye on. The company has proved that it's restaurant recession-proof, and the next earnings release on May 3 will be the first full quarterly report with the six new U.S. and two international locations opened at the end of last year. Perhaps some positive surprises will keep things on the upside.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.