1 /* 2 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * - Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * - Neither the name of Oracle nor the names of its 16 * contributors may be used to endorse or promote products derived 17 * from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * This source code is provided to illustrate the usage of a given feature 34 * or technique and has been deliberately simplified. Additional steps 35 * required for a production-quality application, such as security checks, 36 * input validation and proper error handling, might not be present in 37 * this sample code. 38 */ 39 package stream.data; 40 41 import java.time.LocalDateTime; 42 import java.time.format.DateTimeFormatter; 43 import javax.xml.bind.annotation.XmlElement; 44 import javax.xml.bind.annotation.XmlRootElement; 45 46 /** 47 * Order meta data class 48 * 49 * @author tyan 50 */ 51 @XmlRootElement(name = "order") 52 public class Order { 53 54 /** 55 * @return id of order. 56 */ 57 @XmlElement(name = "id") 58 public int getOrderId() { 59 return orderId; 60 } 61 62 /** 63 * Set orderId 64 * 65 * @param orderId order's id 66 */ 67 public void setOrderId(int orderId) { 68 this.orderId = orderId; 69 } 70 71 /** 72 * @return string of order's date 73 */ 74 public String getOrderdate() { 75 return dtf.format(orderdate); 76 } 77 78 /** 79 * @return order date 80 */ 81 public LocalDateTime getLocalOrderdate() { 82 return orderdate; 83 } 84 85 /** 86 * Set orderdate 87 * 88 * @param orderdate order date 89 */ 90 public void setOrderdate(String orderdate) { 91 this.orderdate = LocalDateTime.parse(orderdate, dtf); 92 } 93 94 /** 95 * @return total number of order 96 */ 97 public double getTotal() { 98 return total; 99 } 100 101 /** 102 * Set total number 103 * 104 * @param total total number of this odder 105 */ 106 public void setTotal(double total) { 107 this.total = total; 108 } 109 110 /** 111 * Id of order. 112 */ 113 private int orderId; 114 115 /** 116 * order date. 117 */ 118 private LocalDateTime orderdate; 119 120 /** 121 * Total number of order. 122 */ 123 private double total; 124 125 /** 126 * Formatter for convert orderdate and String 127 */ 128 private final DateTimeFormatter dtf 129 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); 130 }