Skip to content

Package: CustomerXml

CustomerXml

nameinstructionbranchcomplexitylinemethod
CustomerXml(Customer)
M: 0 C: 25
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
toBuilder()
M: 0 C: 17
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
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.exporter.xml.impl.xml;
27:
28: import javax.annotation.Nonnull;
29: import javax.xml.bind.annotation.XmlAccessorOrder;
30: import javax.xml.bind.annotation.XmlAccessorType;
31: import javax.xml.bind.annotation.XmlAttribute;
32: import javax.xml.bind.annotation.XmlElement;
33: import javax.xml.bind.annotation.XmlID;
34: import javax.xml.bind.annotation.XmlRootElement;
35: import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
36: import it.tidalwave.accounting.exporter.xml.impl.adapters.IdAdapter;
37: import it.tidalwave.accounting.model.Customer;
38: import it.tidalwave.util.Id;
39: import lombok.Getter;
40: import lombok.NoArgsConstructor;
41: import static javax.xml.bind.annotation.XmlAccessOrder.ALPHABETICAL;
42: import static javax.xml.bind.annotation.XmlAccessType.FIELD;
43:
44: /***************************************************************************************************************************************************************
45: *
46: * @author Fabrizio Giudici
47: *
48: **************************************************************************************************************************************************************/
49: //@Mutable
50: @NoArgsConstructor
51: @XmlRootElement(name = "customer") @XmlAccessorType(FIELD) @XmlAccessorOrder(ALPHABETICAL)
52: public class CustomerXml
53: {
54: @Getter // FIXME
55:
56: @XmlAttribute(name = "id")
57: @XmlID
58: @XmlJavaTypeAdapter(IdAdapter.class)
59: private Id id;
60:
61: @XmlElement(name = "name")
62: private String name;
63:
64: @XmlElement(name = "billingAddress")
65: private AddressXml billingAddressXml;
66:
67: @XmlElement(name = "vatNumber")
68: private String vatNumber;
69:
70: public CustomerXml (@Nonnull final Customer customer)
71: {
72: final var builder = customer.toBuilder();
73: this.id = builder.getId();
74: this.name = builder.getName();
75: this.billingAddressXml = new AddressXml(builder.getBillingAddress());
76: this.vatNumber = builder.getVatNumber();
77: }
78:
79: @Nonnull
80: public Customer.Builder toBuilder()
81: {
82: return new Customer.Builder().withId(id)
83: .withName(name)
84: .withBillingAddress(billingAddressXml.toAddress())
85: .withVatNumber(vatNumber);
86: }
87: }