1 /* 2 * ************************************************************************************************************************************************************* 3 * 4 * blueHour: open source accounting 5 * http://tidalwave.it/projects/bluehour 6 * 7 * Copyright (C) 2013 - 2024 by Tidalwave s.a.s. (http://tidalwave.it) 8 * 9 * ************************************************************************************************************************************************************* 10 * 11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 12 * You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * 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 17 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 18 * 19 * ************************************************************************************************************************************************************* 20 * 21 * git clone https://bitbucket.org/tidalwave/bluehour-src 22 * git clone https://github.com/tidalwave-it/bluehour-src 23 * 24 * ************************************************************************************************************************************************************* 25 */ 26 package it.tidalwave.accounting.model.impl; 27 28 import javax.annotation.Nonnull; 29 import it.tidalwave.accounting.model.Customer; 30 import it.tidalwave.accounting.model.Invoice; 31 import it.tidalwave.accounting.model.JobEvent; 32 import it.tidalwave.accounting.model.Project; 33 import it.tidalwave.accounting.model.spi.ObjectFactory; 34 35 /*************************************************************************************************************************************************************** 36 * 37 * @author Fabrizio Giudici 38 * 39 **************************************************************************************************************************************************************/ 40 public class InMemoryObjectFactory implements ObjectFactory 41 { 42 @Override @Nonnull 43 public Customer createCustomer (@Nonnull final Customer.Builder builder) 44 { 45 return new InMemoryCustomer(builder); 46 } 47 48 @Override @Nonnull 49 public Invoice createInvoice (@Nonnull final Invoice.Builder builder) 50 { 51 return new InMemoryInvoice(builder); 52 } 53 54 @Override @Nonnull 55 public Project createProject (@Nonnull final Project.Builder builder) 56 { 57 return new InMemoryProject(builder); 58 } 59 60 @Override @Nonnull 61 public JobEvent createJobEvent (@Nonnull final JobEvent.Builder builder) 62 { 63 final var events = builder.getEvents(); 64 65 if ((events != null) && !events.isEmpty()) 66 { 67 return new InMemoryJobEventGroup(builder); 68 } 69 else if (builder.getType() == JobEvent.Type.TIMED) 70 { 71 return new InMemoryTimedJobEvent(builder); 72 } 73 else 74 { 75 return new InMemoryFlatJobEvent(builder); 76 } 77 } 78 }