Content of file InMemoryProject.java.html
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>InMemoryProject.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">blueHour - Model, In-Memory Implementation</a> > <a href="index.source.html" class="el_package">it.tidalwave.accounting.model.impl</a> > <span class="el_source">InMemoryProject.java</span></div><h1>InMemoryProject.java</h1><pre class="source lang-java linenums">/*
* #%L
* *********************************************************************************************************************
*
* blueHour
* http://bluehour.tidalwave.it - git clone git@bitbucket.org:tidalwave/bluehour-src.git
* %%
* Copyright (C) 2013 - 2021 Tidalwave s.a.s. (http://tidalwave.it)
* %%
* *********************************************************************************************************************
*
* 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.
*
* *********************************************************************************************************************
*
* $Id$
*
* *********************************************************************************************************************
* #L%
*/
package it.tidalwave.accounting.model.impl;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;
import java.time.Duration;
import java.time.LocalDate;
import java.util.List;
import it.tidalwave.util.Id;
import it.tidalwave.util.spi.AsSupport;
import it.tidalwave.accounting.model.Accounting;
import it.tidalwave.accounting.model.Customer;
import it.tidalwave.accounting.model.Project;
import it.tidalwave.accounting.model.Project.Builder;
import it.tidalwave.accounting.model.ProjectRegistry.JobEventFinder;
import it.tidalwave.accounting.model.types.Money;
import it.tidalwave.accounting.model.spi.ProjectSpi;
import lombok.AllArgsConstructor;
import lombok.experimental.Delegate;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.With;
import static lombok.AccessLevel.PRIVATE;
/***********************************************************************************************************************
*
* This class models a project.
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
@Immutable @With
<span class="pc bnc" id="L62" title="All 140 branches missed.">@AllArgsConstructor(access = PRIVATE) @EqualsAndHashCode @ToString(exclude = {"events", "asSupport", "accounting"})</span>
public class InMemoryProject implements ProjectSpi
{
<span class="nc" id="L65"> @Setter // FIXME</span>
<span class="nc bnc" id="L66" title="All 2 branches missed."> private Accounting accounting;</span>
<span class="pc" id="L68"> @Delegate</span>
private final AsSupport asSupport = new AsSupport(this);
<span class="fc" id="L71"> @Getter @Nonnull</span>
<span class="nc bnc" id="L72" title="All 4 branches missed."> private final Id id;</span>
<span class="fc" id="L74"> @Getter @Nonnull</span>
<span class="nc bnc" id="L75" title="All 4 branches missed."> private final Customer customer;</span>
<span class="fc" id="L77"> @Getter @Nonnull</span>
<span class="nc bnc" id="L78" title="All 4 branches missed."> private final String name;</span>
<span class="fc" id="L80"> @Getter @Nonnull</span>
<span class="nc bnc" id="L81" title="All 4 branches missed."> private final String number;</span>
<span class="fc" id="L83"> @Getter @Nonnull</span>
<span class="nc bnc" id="L84" title="All 4 branches missed."> private final String description;</span>
<span class="fc" id="L86"> @Getter @Nonnull</span>
<span class="nc bnc" id="L87" title="All 4 branches missed."> private final String notes;</span>
<span class="fc" id="L89"> @Getter</span>
<span class="nc bnc" id="L90" title="All 2 branches missed."> private final Status status;</span>
<span class="fc" id="L92"> @Getter @Nonnull</span>
<span class="nc bnc" id="L93" title="All 4 branches missed."> private final Money hourlyRate;</span>
<span class="fc" id="L95"> @Getter @Nonnull</span>
<span class="nc bnc" id="L96" title="All 4 branches missed."> private final Money budget;</span>
<span class="fc" id="L98"> @Getter @Nonnull</span>
<span class="nc bnc" id="L99" title="All 4 branches missed."> private final LocalDate startDate;</span>
<span class="fc" id="L101"> @Getter @Nonnull</span>
<span class="nc bnc" id="L102" title="All 4 branches missed."> private final LocalDate endDate;</span>
@Nonnull
<span class="nc bnc" id="L105" title="All 4 branches missed."> private final List<InMemoryJobEvent> events; // FIXME: immutable</span>
/*******************************************************************************************************************
*
*
*
******************************************************************************************************************/
public /* FIXME protected */ InMemoryProject (final @Nonnull Builder builder)
<span class="fc" id="L113"> {</span>
<span class="fc" id="L114"> this.id = builder.getId();</span>
<span class="fc" id="L115"> this.customer = builder.getCustomer();</span>
<span class="fc" id="L116"> this.name = builder.getName();</span>
<span class="fc" id="L117"> this.number = builder.getNumber();</span>
<span class="fc" id="L118"> this.description = builder.getDescription();</span>
<span class="fc" id="L119"> this.notes = builder.getNotes();</span>
<span class="fc" id="L120"> this.status = builder.getStatus();</span>
<span class="fc" id="L121"> this.hourlyRate = builder.getHourlyRate();</span>
<span class="fc" id="L122"> this.budget = builder.getBudget();</span>
<span class="fc" id="L123"> this.startDate = builder.getStartDate();</span>
<span class="fc" id="L124"> this.endDate = builder.getEndDate();</span>
<span class="fc" id="L125"> this.events = (List<InMemoryJobEvent>)builder.getEvents();</span>
<span class="fc" id="L126"> }</span>
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public JobEventFinder findChildren()
{
<span class="nc" id="L136"> return new InMemoryJobEventFinderFromList(events);</span>
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public Money getEarnings()
{
<span class="nc" id="L147"> return findChildren().getEarnings();</span>
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public Duration getDuration()
{
<span class="nc" id="L158"> return findChildren().getDuration();</span>
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public Money getInvoicedEarnings()
{
<span class="nc" id="L169"> return accounting.getInvoiceRegistry().findInvoices().withProject(this).getEarnings();</span>
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public Builder toBuilder()
{
<span class="nc" id="L180"> return new Builder(id, customer, name, number, description, notes, status, hourlyRate, budget, </span>
startDate, endDate, events, Project.Builder.Callback.DEFAULT);
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.6.202009150832</span></div></body></html>