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 - 2023 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.
*
* *********************************************************************************************************************
*
*
* *********************************************************************************************************************
* #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.As;
import it.tidalwave.util.Id;
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
*
**********************************************************************************************************************/
@Immutable @With
<span class="pc bnc" id="L60" title="All 118 branches missed.">@AllArgsConstructor(access = PRIVATE) @EqualsAndHashCode @ToString(exclude = {"events", "as", "accounting"})</span>
public class InMemoryProject implements ProjectSpi
{
<span class="fc" id="L63"> @Setter // FIXME</span>
<span class="nc bnc" id="L64" title="All 2 branches missed."> private Accounting accounting;</span>
<span class="pc" id="L66"> @Delegate</span>
<span class="pc" id="L67"> private final As as = As.forObject(this);</span>
<span class="fc" id="L69"> @Getter @Nonnull</span>
<span class="nc bnc" id="L70" title="All 2 branches missed."> private final Id id;</span>
<span class="fc" id="L72"> @Getter @Nonnull</span>
<span class="nc bnc" id="L73" title="All 2 branches missed."> private final Customer customer;</span>
<span class="fc" id="L75"> @Getter @Nonnull</span>
<span class="nc bnc" id="L76" title="All 2 branches missed."> private final String name;</span>
<span class="fc" id="L78"> @Getter @Nonnull</span>
<span class="nc bnc" id="L79" title="All 2 branches missed."> private final String number;</span>
<span class="fc" id="L81"> @Getter @Nonnull</span>
<span class="nc bnc" id="L82" title="All 2 branches missed."> private final String description;</span>
<span class="fc" id="L84"> @Getter @Nonnull</span>
<span class="nc bnc" id="L85" title="All 2 branches missed."> private final String notes;</span>
<span class="fc" id="L87"> @Getter</span>
<span class="nc bnc" id="L88" title="All 2 branches missed."> private final Status status;</span>
<span class="fc" id="L90"> @Getter @Nonnull</span>
<span class="nc bnc" id="L91" title="All 2 branches missed."> private final Money hourlyRate;</span>
<span class="fc" id="L93"> @Getter @Nonnull</span>
<span class="nc bnc" id="L94" title="All 2 branches missed."> private final Money budget;</span>
<span class="fc" id="L96"> @Getter @Nonnull</span>
<span class="nc bnc" id="L97" title="All 2 branches missed."> private final LocalDate startDate;</span>
<span class="fc" id="L99"> @Getter @Nonnull</span>
<span class="nc bnc" id="L100" title="All 2 branches missed."> private final LocalDate endDate;</span>
@Nonnull
<span class="nc bnc" id="L103" title="All 2 branches missed."> private final List<InMemoryJobEvent> events; // FIXME: immutable</span>
/*******************************************************************************************************************
*
*
*
******************************************************************************************************************/
public /* FIXME protected */ InMemoryProject (@Nonnull final Builder builder)
<span class="fc" id="L111"> {</span>
<span class="fc" id="L112"> this.id = builder.getId();</span>
<span class="fc" id="L113"> this.customer = builder.getCustomer();</span>
<span class="fc" id="L114"> this.name = builder.getName();</span>
<span class="fc" id="L115"> this.number = builder.getNumber();</span>
<span class="fc" id="L116"> this.description = builder.getDescription();</span>
<span class="fc" id="L117"> this.notes = builder.getNotes();</span>
<span class="fc" id="L118"> this.status = builder.getStatus();</span>
<span class="fc" id="L119"> this.hourlyRate = builder.getHourlyRate();</span>
<span class="fc" id="L120"> this.budget = builder.getBudget();</span>
<span class="fc" id="L121"> this.startDate = builder.getStartDate();</span>
<span class="fc" id="L122"> this.endDate = builder.getEndDate();</span>
<span class="fc" id="L123"> this.events = (List<InMemoryJobEvent>)builder.getEvents();</span>
<span class="fc" id="L124"> }</span>
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public JobEventFinder findChildren()
{
<span class="fc" id="L134"> return new InMemoryJobEventFinderFromList(events);</span>
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public Money getEarnings()
{
<span class="fc" id="L145"> return findChildren().getEarnings();</span>
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public Duration getDuration()
{
<span class="fc" id="L156"> return findChildren().getDuration();</span>
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public Money getInvoicedEarnings()
{
<span class="nc" id="L167"> return accounting.getInvoiceRegistry().findInvoices().withProject(this).getEarnings();</span>
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public Builder toBuilder()
{
<span class="nc" id="L178"> 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.7.202105040129</span></div></body></html>