Package br.com.colegio.dao.storage

Source Code of br.com.colegio.dao.storage.LancamentoData

package br.com.colegio.dao.storage;

import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;

import br.com.colegio.dao.LancamentoDAO;
import br.com.colegio.vo.Lancamento;

public class LancamentoData
{
  private static LancamentoData instance;
  private Map<Long, Lancamento> data = new TreeMap<Long, Lancamento>();

  private LancamentoData()
  {
  }

  public static LancamentoData getInstance()
  {
    if (instance == null)
      instance = new LancamentoData();

    return instance;
  }

  private Map<Long, Lancamento> getData()
  {
    if (data.size() == 0)
    {
      Collection<Object> r = LancamentoDAO.list();

      if (r != null)
        for (Object o : r)
        {
          Lancamento a = (Lancamento)o;
          data.put(a.getKey().getId(), a);
        }
    }

    return data;
  }

  public Lancamento getLancamento(Long id)
  {
    return getData().get(id);
  }

  public Collection<Lancamento> getLancamentos()
  {
    return getData().values();
  }
}
TOP

Related Classes of br.com.colegio.dao.storage.LancamentoData

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.