View Javadoc
1   /*
2    * Copyright (c) 2023. Roland T. Lichti, Kaiserpfalz EDV-Service.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16   */
17  
18  package de.kaiserpfalzedv.services.eansearch.model;
19  
20  import com.fasterxml.jackson.annotation.JsonIgnore;
21  import com.fasterxml.jackson.annotation.JsonInclude;
22  import lombok.AllArgsConstructor;
23  import lombok.Builder;
24  import lombok.Getter;
25  import lombok.NoArgsConstructor;
26  import lombok.experimental.SuperBuilder;
27  import lombok.extern.jackson.Jacksonized;
28  
29  /**
30   * <p>VerifyChecksumResponse -- Verified the checksum of an EAN code.</p>
31   *
32   * @author rlichti {@literal <rlichti@kaiserpfalz-edv.de>}
33   * @since 3.0.0  2023-01-17
34   */
35  @Jacksonized
36  @SuperBuilder(toBuilder = true)
37  @AllArgsConstructor
38  @NoArgsConstructor
39  @Getter
40  @JsonInclude(JsonInclude.Include.NON_ABSENT)
41  public class VerifyChecksumResponse {
42      Product product;
43  
44      @JsonIgnore
45      public String getEan() {
46          return product.getEan();
47      }
48  
49      @JsonIgnore
50      public boolean isValid() {
51          return product.isValid();
52      }
53  
54      @Jacksonized
55      @Builder(toBuilder = true)
56      @AllArgsConstructor
57      @NoArgsConstructor
58      @Getter
59      @JsonInclude(JsonInclude.Include.NON_ABSENT)
60      public static class Product {
61          String ean;
62          Integer valid;
63  
64          @JsonIgnore
65          boolean isValid() {
66              return valid == 1;
67          }
68      }
69  }