1
2
3
4
5
6
7
8
9
10
11 package org.mule.example.cep;
12
13 import java.text.DecimalFormat;
14
15
16
17
18
19
20 public class StockTick
21 {
22 private final String symbol;
23 private final double price;
24 private final long timestamp;
25 private double delta;
26 private String str;
27
28 public StockTick(String symbol, double price, long timestamp)
29 {
30 super();
31 this.symbol = symbol;
32 this.price = price;
33 this.timestamp = timestamp;
34 this.str = createString();
35 }
36
37 public String getSymbol()
38 {
39 return symbol;
40 }
41
42 public double getPrice()
43 {
44 return price;
45 }
46
47 public long getTimestamp()
48 {
49 return timestamp;
50 }
51
52 public String toString()
53 {
54 return str;
55 }
56
57 private String createString()
58 {
59 return symbol + " $" + price;
60 }
61
62 public double getDelta()
63 {
64 return delta;
65 }
66
67 public void setDelta(double delta)
68 {
69 this.delta = delta;
70 this.str = createString();
71 }
72
73 public static String percent(double number)
74 {
75 return new DecimalFormat("0.0%").format(number);
76 }
77 }