Content of file InMemoryCustomer.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>InMemoryCustomer.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">InMemoryCustomer.java</span></div><h1>InMemoryCustomer.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.util.Map;
import it.tidalwave.util.Id;
import it.tidalwave.util.spi.AsSupport;
import it.tidalwave.accounting.model.Accounting;
import it.tidalwave.accounting.model.Project;
import it.tidalwave.accounting.model.ProjectRegistry;
import it.tidalwave.accounting.model.types.Address;
import it.tidalwave.accounting.model.spi.CustomerSpi;
import it.tidalwave.accounting.model.spi.util.FinderWithIdMapSupport;
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import static java.util.stream.Collectors.toMap;
/***********************************************************************************************************************
*
* This class models a customer.
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
<span class="pc bnc" id="L56" title="All 54 branches missed.">@Immutable @Getter @EqualsAndHashCode @ToString(exclude = {"accounting", "asSupport"}) // FIXME: remove the @Getter</span>
public class InMemoryCustomer implements CustomerSpi
{
private static final long serialVersionUID = 1L;
static class InMemoryProjectFinder extends FinderWithIdMapSupport<Project, InMemoryProject, ProjectRegistry.ProjectFinder>
implements ProjectRegistry.ProjectFinder
{
private static final long serialVersionUID = 1L;
public InMemoryProjectFinder (final @Nonnull InMemoryProjectFinder other, final @Nonnull Object override)
{
<span class="nc" id="L68"> super(other, override); </span>
<span class="nc" id="L69"> }</span>
InMemoryProjectFinder (final @Nonnull Map<Id, InMemoryProject> projectMapById)
{
<span class="nc" id="L73"> super(projectMapById); </span>
<span class="nc" id="L74"> }</span>
}
<span class="pc" id="L77"> @Delegate</span>
<span class="nc" id="L78"> private final AsSupport asSupport = new AsSupport(this);</span>
<span class="fc" id="L80"> @Getter @Nonnull</span>
private final Id id;
@Nonnull
<span class="fc" id="L84"> private final String name;</span>
@Nonnull
<span class="fc" id="L87"> private final Address billingAddress;</span>
@Nonnull
<span class="fc" id="L90"> private final String vatNumber;</span>
<span class="nc bnc" id="L92" title="All 2 branches missed."> @Setter @Nonnull // FIXME: drop the setter!</span>
<span class="nc" id="L93"> private Accounting accounting;</span>
/*******************************************************************************************************************
*
*
*
******************************************************************************************************************/
public /* FIXME protected */ InMemoryCustomer (final @Nonnull Builder builder)
<span class="fc" id="L101"> {</span>
<span class="fc" id="L102"> this.id = builder.getId();</span>
<span class="fc" id="L103"> this.name = builder.getName();</span>
<span class="fc" id="L104"> this.billingAddress = builder.getBillingAddress();</span>
<span class="fc" id="L105"> this.vatNumber = builder.getVatNumber();</span>
<span class="fc" id="L106"> }</span>
/*******************************************************************************************************************
*
*
*
******************************************************************************************************************/
@Override @Nonnull
public ProjectRegistry.ProjectFinder findProjects()
{
<span class="nc" id="L116"> return new InMemoryProjectFinder(accounting.getProjectRegistry().findProjects()</span>
<span class="nc" id="L117"> .stream()</span>
<span class="nc" id="L118"> .filter(project -> project.getCustomer().getId().equals(getId()))</span>
<span class="nc" id="L119"> .collect(toMap(Project::getId, project -> (InMemoryProject)project)));</span>
}
/*******************************************************************************************************************
*
* @return
*
******************************************************************************************************************/
@Override @Nonnull
public Builder toBuilder()
{
<span class="nc" id="L130"> return new Builder(id, name, billingAddress, vatNumber, InMemoryCustomer.Builder.Callback.DEFAULT); </span>
}
}
</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>