O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

StockUpdate adjustments

First of all, let's add the necessary fields for the text:

private final String twitterStatus;[...]public StockUpdate(String stockSymbol, BigDecimal price, Date date,     String twitterStatus) {    if (stockSymbol == null) {        stockSymbol = "";    }    if (twitterStatus == null) {        twitterStatus = "";    }    this.stockSymbol = stockSymbol;    this.price = price;    this.date = date;    this.twitterStatus = twitterStatus;}

Here, we have added some additional checks so that we won't run into NullPointerException later on. Also, the existing .create() method has to be updated to the following:

public static StockUpdate create(YahooStockQuote r) {    return new StockUpdate(r.getSymbol(), r.getLastTradePriceOnly(),         new Date(), "");}

Later, we will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required