@@ -0,0 +1,2907 @@
+//snippet-sourcedescription:%5BStockTrade.java is a helper class%5D%0A//snippet-keyword:%5BSDK for Java 2.0%5D%0A//snippet-keyword:%5BCode Sample%5D%0A//snippet-service:%5BAmazon Kinesis Data Firehose%5D%0A//snippet-sourcetype:%5Bfull-example%5D%0A//snippet-sourcedate:%5B7/6/2020%5D%0A//snippet-sourceauthor:%5Bscmacdon - aws%5D%0A%0A/*%0A * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22).%0A * You may not use this file except in compliance with the License.%0A * A copy of the License is located at%0A *%0A *  http://aws.amazon.com/apache2.0%0A *%0A * or in the %22license%22 file accompanying this file. This file is distributed%0A * on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either%0A * express or implied. See the License for the specific language governing%0A * permissions and limitations under the License.%0A */%0A%0Apackage com.example.firehose;%0A%0Aimport java.io.IOException;%0A%0Aimport com.fasterxml.jackson.databind.DeserializationFeature;%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0A%0A/**%0A * Captures the key elements of a stock trade, such as the ticker symbol, price,%0A * number of shares, the type of the trade (buy or sell), and an id uniquely identifying%0A * the trade.%0A */%0Apublic class StockTrade %7B%0A%0A    private final static ObjectMapper JSON = new ObjectMapper();%0A    static %7B%0A        JSON.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);%0A    %7D%0A%0A    /**%0A     * Represents the type of the stock trade eg buy or sell.%0A     */%0A    public enum TradeType %7B%0A        BUY,%0A        SELL%0A    %7D%0A%0A    private String tickerSymbol;%0A    private TradeType tradeType;%0A    private double price;%0A    private long quantity;%0A    private long id;%0A%0A    public StockTrade() %7B%0A    %7D%0A%0A    public StockTrade(String tickerSymbol, TradeType tradeType, double price, long quantity, long id) %7B%0A        this.tickerSymbol = tickerSymbol;%0A        this.tradeType = tradeType;%0A        this.price = price;%0A        this.quantity = quantity;%0A        this.id = id;%0A    %7D%0A%0A    public String getTickerSymbol() %7B%0A        return tickerSymbol;%0A    %7D%0A%0A    public TradeType getTradeType() %7B%0A        return tradeType;%0A    %7D%0A%0A    public double getPrice() %7B%0A        return price;%0A    %7D%0A%0A    public long getQuantity() %7B%0A        return quantity;%0A    %7D%0A%0A    public long getId() %7B%0A        return id;%0A    %7D%0A%0A    public byte%5B%5D toJsonAsBytes() %7B%0A        try %7B%0A            return JSON.writeValueAsBytes(this);%0A        %7D catch (IOException e) %7B%0A            return null;%0A        %7D%0A    %7D%0A%0A    public static StockTrade fromJsonAsBytes(byte%5B%5D bytes) %7B%0A        try %7B%0A            return JSON.readValue(bytes, StockTrade.class);%0A        %7D catch (IOException e) %7B%0A            return null;%0A        %7D%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        return String.format(%22ID %25d: %25s %25d shares of %25s for $%25.02f%22,%0A                id, tradeType, quantity, tickerSymbol, price);%0A    %7D%0A%0A%7D%0A

Create StockTrade.java