br.com.objectos.way.cmatic.ConstrutorDeLancamentoMM Maven / Gradle / Ivy
/*
* Copyright 2013 Objectos, Fábrica de Software LTDA.
*
* 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.
*/
package br.com.objectos.way.cmatic;
import static com.google.common.collect.Lists.newArrayList;
import java.util.List;
import org.joda.time.LocalDate;
import br.com.objectos.comuns.base.Construtor;
import com.google.common.collect.ImmutableList;
/**
* @author [email protected] (Edenir Norberto Anschau)
*/
public class ConstrutorDeLancamentoMM implements LancamentoMM.Construtor, Construtor {
private final int numero;
private final LocalDate data;
private double valorDebito;
private double valorCredito;
private final List lancamentos = newArrayList();
ConstrutorDeLancamentoMM(int numero, LocalDate data) {
this.numero = numero;
this.data = data;
}
@Override
public LancamentoMM novaInstancia() {
return LancamentoMM.of(this);
}
public ConstrutorDeLancamentoMM add(SubLancamento lancamento) {
valorDebito += lancamento.getValorDebito();
valorCredito += lancamento.getValorCredito();
lancamentos.add(lancamento);
return this;
}
public ConstrutorDeLancamentoMM addAll(Iterable extends SubLancamento.CMatic> cmatics) {
for (SubLancamento.CMatic cmatic : cmatics) {
SubLancamento lancamento = SubLancamento.of(cmatic);
add(lancamento);
}
return this;
}
@Override
public int getNumero() {
return numero;
}
@Override
public LocalDate getData() {
return data;
}
@Override
public double getValorDebito() {
return valorDebito;
}
@Override
public double getValorCredito() {
return valorCredito;
}
@Override
public List getLancamentos() {
return ImmutableList.copyOf(lancamentos);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy