View Javadoc

1   /*
2    * $Id: Company.java 20896 2011-01-05 13:17:51Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.example.cep;
12  
13  /**
14   * A POJO for a company
15   * 
16   * @author etirelli
17   */
18  public class Company
19  {
20      private String name;
21      private String symbol;
22      private double currentPrice;
23      private double previousPrice;
24  
25      public Company(String name, String symbol)
26      {
27          this(name, symbol, 0, 0);
28      }
29  
30      public Company(String name, String symbol, double current, double previous)
31      {
32          this.name = name;
33          this.symbol = symbol;
34          this.currentPrice = current;
35          this.previousPrice = previous;
36      }
37  
38      public String getName()
39      {
40          return name;
41      }
42  
43      public void setName(String name)
44      {
45          this.name = name;
46      }
47  
48      public String getSymbol()
49      {
50          return symbol;
51      }
52  
53      public void setSymbol(String symbol)
54      {
55          this.symbol = symbol;
56      }
57  
58      public double getCurrentPrice()
59      {
60          return currentPrice;
61      }
62  
63      public void setCurrentPrice(double current)
64      {
65          this.previousPrice = this.currentPrice;
66          this.currentPrice = current;
67      }
68  
69      public double getPreviousPrice()
70      {
71          return previousPrice;
72      }
73  
74      public double getDelta()
75      {
76          return (previousPrice == 0) ? 0.0 : ((currentPrice / previousPrice) - 1.0);
77      }
78  
79  }