Skip to content

Package: Customer$Builder$Callback

Customer$Builder$Callback

nameinstructionbranchcomplexitylinemethod
lambda$static$0(Customer)
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

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;
27:
28: import javax.annotation.Nonnull;
29: import javax.annotation.concurrent.Immutable;
30: import it.tidalwave.accounting.model.spi.ObjectFactory;
31: import it.tidalwave.accounting.model.types.Address;
32: import it.tidalwave.util.As;
33: import it.tidalwave.util.Id;
34: import it.tidalwave.role.Identifiable;
35: import lombok.AllArgsConstructor;
36: import lombok.Getter;
37: import lombok.ToString;
38: import lombok.With;
39:
40: /***************************************************************************************************************************************************************
41: *
42: * This class models a customer.
43: *
44: * @author Fabrizio Giudici
45: *
46: **************************************************************************************************************************************************************/
47: public interface Customer extends Identifiable, As
48: {
49: /***********************************************************************************************************************************************************
50: *
51: **********************************************************************************************************************************************************/
52: @AllArgsConstructor // FIXME (access = PROTECTED)
53: @Immutable @With @Getter @ToString
54: public static class Builder
55: {
56: public static interface Callback // Lombok @With doesn't support builder subclasses
57: {
58: public void register (@Nonnull final Customer customer);
59:
60: public static final Callback DEFAULT = (customer) -> {};
61: }
62:
63: private final Id id;
64: private final String name;
65: private final Address billingAddress;
66: private final String vatNumber;
67: private final Callback callback;
68:
69: public Builder()
70: {
71: this(Callback.DEFAULT);
72: }
73:
74: public Builder (@Nonnull final Callback callback)
75: {
76: this(new Id(""), "", Address.EMPTY, "", callback);
77: }
78:
79: @Nonnull
80: public Builder with (@Nonnull final Builder builder)
81: {
82: return builder.withCallback(callback);
83: }
84:
85: @Nonnull
86: public Customer create()
87: {
88: final var customer = ObjectFactory.getInstance().createCustomer(this);
89: callback.register(customer);
90: return customer;
91: }
92: }
93:
94: /***********************************************************************************************************************************************************
95: *
96: **********************************************************************************************************************************************************/
97: @Nonnull
98: public static Builder builder()
99: {
100: return new Builder();
101: }
102:
103: /***********************************************************************************************************************************************************
104: *
105: **********************************************************************************************************************************************************/
106: @Nonnull
107: public ProjectRegistry.ProjectFinder findProjects();
108:
109: /***********************************************************************************************************************************************************
110: * Returns a builder pre-populated with all the attributes.
111: *
112: * @return the builder
113: **********************************************************************************************************************************************************/
114: @Nonnull
115: public Builder toBuilder();
116: }