After updating to Appium 2 I am unable to compare and check if the platform is Android or iOS

Hi ,
I recently updated the Appium to Appium 2 and while doing so I noticed that I am unable to compare and check if the platform is Android or iOS .

In previous version of Appium i used to Use

if(driver.getPlatformName.equals("Android"))

After updating i am getting error .
Thanks

I kind of re-wrote the code like this

if(driver instanceof AndroidDriver)

Reference link: