Skip to content

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 - Application (JavaFX)</a> &gt; <a href="../index.html" class="el_bundle">it-tidalwave-accounting-model-impl-inmemory</a> &gt; <a href="index.source.html" class="el_package">it.tidalwave.accounting.model.impl</a> &gt; <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 &quot;License&quot;); 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 &quot;AS IS&quot; 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.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
 *
 **********************************************************************************************************************/
<span class="pc bnc" id="L54" title="All 54 branches missed.">@Immutable @Getter @EqualsAndHashCode @ToString(exclude = {&quot;accounting&quot;, &quot;asSupport&quot;}) // FIXME: remove the @Getter</span>
public class InMemoryCustomer implements CustomerSpi
  {
    private static final long serialVersionUID = 1L;
    
    static class InMemoryProjectFinder extends FinderWithIdMapSupport&lt;Project, InMemoryProject, ProjectRegistry.ProjectFinder&gt;
                                implements ProjectRegistry.ProjectFinder
      {
        private static final long serialVersionUID = 1L;
    
        public InMemoryProjectFinder (@Nonnull final InMemoryProjectFinder other, @Nonnull final Object override)
          {
<span class="nc" id="L66">            super(other, override);  </span>
<span class="nc" id="L67">          }</span>
        
        InMemoryProjectFinder (@Nonnull final Map&lt;Id, InMemoryProject&gt; projectMapById)
          {
<span class="nc" id="L71">            super(projectMapById);  </span>
<span class="nc" id="L72">          }</span>
      }
    
<span class="pc" id="L75">    @Delegate</span>
<span class="nc" id="L76">    private final AsSupport asSupport = new AsSupport(this);</span>

<span class="fc" id="L78">    @Getter @Nonnull</span>
    private final Id id;

    @Nonnull
<span class="fc" id="L82">    private final String name;</span>

    @Nonnull
<span class="fc" id="L85">    private final Address billingAddress;</span>

    @Nonnull
<span class="fc" id="L88">    private final String vatNumber;</span>
    
<span class="nc" id="L90">    @Setter @Nonnull // FIXME: drop the setter!</span>
drop the setter!
<span class="nc" id="L91"> private Accounting accounting;</span> /******************************************************************************************************************* * * * ******************************************************************************************************************/ public /* FIXME protected */ InMemoryCustomer (@Nonnull final Builder builder) <span class="fc" id="L99"> {</span> <span class="fc" id="L100"> this.id = builder.getId();</span> <span class="fc" id="L101"> this.name = builder.getName();</span> <span class="fc" id="L102"> this.billingAddress = builder.getBillingAddress();</span> <span class="fc" id="L103"> this.vatNumber = builder.getVatNumber();</span> <span class="fc" id="L104"> }</span> /******************************************************************************************************************* * * * ******************************************************************************************************************/ @Override @Nonnull public ProjectRegistry.ProjectFinder findProjects() { <span class="nc" id="L114"> return new InMemoryProjectFinder(accounting.getProjectRegistry().findProjects()</span> <span class="nc" id="L115"> .stream()</span> <span class="nc" id="L116"> .filter(project -&gt; project.getCustomer().getId().equals(getId()))</span> <span class="nc" id="L117"> .collect(toMap(Project::getId, project -&gt; (InMemoryProject)project)));</span> } /******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public Builder toBuilder() { <span class="nc" id="L128"> 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>