cacheRunner.Position Maven / Gradle / Ivy
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
package cacheRunner;
import java.util.*;
import java.io.Serializable;
import com.gemstone.gemfire.cache.Declarable;
/**
* Represents a number of shares of a stock ("security") held in a
* {@link Portfolio}.
*
*
*
* This class is Serializable
because we want it to be
* distributed to multiple members of a distributed system. Because
* this class is Declarable
, we can describe instances of
* it in a GemFire cache.xml
file.
*
* @author GemStone Systems, Inc.
* @since 4.0
*/
public class Position implements Declarable, Serializable {
private String secId;
private double qty;
private double mktValue;
public void init(Properties props) {
this.secId = props.getProperty("secId");
this.qty = Double.parseDouble(props.getProperty("qty"));
this.mktValue = Double.parseDouble(props.getProperty("mktValue"));
}
/**
* Returns the id of the security held in this position.
*/
public String getSecId(){
return this.secId;
}
/**
* Returns the number of shares held in this position.
*/
public double getQty(){
return this.qty;
}
/**
* Returns the value of this position.
*/
public double getMktValue() {
return this.mktValue;
}
@Override
public String toString(){
return "Position [secId="+secId+" qty="+this.qty+" mktValue="+mktValue+"]";
}
}