Package com.wesabe.api.accounts.presenters

Source Code of com.wesabe.api.accounts.presenters.InvestmentPositionPresenter

package com.wesabe.api.accounts.presenters;

import java.util.Locale;

import com.wesabe.api.accounts.entities.InvestmentPosition;
import com.wesabe.xmlson.XmlsonObject;
import com.google.inject.Inject;

/**
* A presenter for {@link InvestmentPosition} instances
*
* @author brad
*
*/
public class InvestmentPositionPresenter {
  private final MoneyPresenter moneyPresenter;
  private final InvestmentSecurityPresenter investmentSecurityPresenter;
 
  @Inject
  public InvestmentPositionPresenter(MoneyPresenter moneyPresenter,
      InvestmentSecurityPresenter investmentSecurityPresenter) {
    this.moneyPresenter = moneyPresenter;
    this.investmentSecurityPresenter = investmentSecurityPresenter;
  }
 
  public XmlsonObject present(InvestmentPosition position, Locale locale) {
    final XmlsonObject root = new XmlsonObject("investment-position");
    if (position.getInvestmentSecurity() != null) {
      root.add(investmentSecurityPresenter.present(position.getInvestmentSecurity()));
    } else {
      root.addNullProperty("investment-security");
    }
    root.addProperty("units", position.getUnits());
    root.add(moneyPresenter.present("unit-price", position.getUnitPrice(), locale));
    root.add(moneyPresenter.present("market-value", position.getMarketValue(), locale));
    return root;
  }
}
TOP

Related Classes of com.wesabe.api.accounts.presenters.InvestmentPositionPresenter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.