Skip to content

Package: FingerprintEntity

FingerprintEntity

nameinstructionbranchcomplexitylinemethod
equals(Object)
M: 1 C: 23
96%
M: 2 C: 6
75%
M: 2 C: 3
60%
M: 0 C: 5
100%
M: 0 C: 1
100%
hashCode()
M: 0 C: 4
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: * SolidBlue 3: Data safety
5: * http://tidalwave.it/projects/solidblue3
6: *
7: * Copyright (C) 2023 - 2023 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
12: * the License. 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
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/solidblue3j-src
23: * git clone https://github.com/tidalwave-it/solidblue3j-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.datamanager.dao.impl.jpa;
28:
29: import java.time.LocalDateTime;
30: import java.util.Objects;
31: import jakarta.persistence.Column;
32: import jakarta.persistence.Entity;
33: import jakarta.persistence.Id;
34: import jakarta.persistence.Index;
35: import jakarta.persistence.Table;
36: import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
37: import lombok.AllArgsConstructor;
38: import lombok.Getter;
39: import lombok.NoArgsConstructor;
40: import lombok.ToString;
41:
42: /***********************************************************************************************************************
43: *
44: * A JPA Entity for {@link it.tidalwave.datamanager.model.Fingerprint}.
45: *
46: * @stereotype JPA Entity
47: * @author Fabrizio Giudici
48: *
49: **********************************************************************************************************************/
50: @Entity
51: @Table(name="fingerprints", indexes = {@Index(name = "fingerprints__id", columnList = "id"),
52: @Index(name = "fingerprints__name", columnList = "name"),
53: @Index(name = "fingerprints__timestamp", columnList = "timestamp"),
54: @Index(name = "fingerprints__fingerprint", columnList = "fingerprint"),
55: @Index(name = "fingerprints__file_id", columnList = "file_id")})
56: @NoArgsConstructor @AllArgsConstructor @Getter @ToString
57: @SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
58: public class FingerprintEntity
59: {
60: @Id
61: @Column(length = 36)
62: private String id;
63:
64: @Column(nullable = false, columnDefinition = "text")
65: private String name;
66:
67: @Column(nullable = false, length = 16)
68: private String algorithm;
69:
70: @Column(name = "fingerprint", nullable = false, length = 32)
71: private String value;
72:
73: @Column(nullable = false)
74: private LocalDateTime timestamp;
75:
76: @Column(name = "file_id", nullable = false, length = 36)
77: private String fileId;
78:
79: // See https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
80: @Override
81: public boolean equals (final Object other)
82: {
83:• if (this == other)
84: {
85: return true;
86: }
87:
88:• if (!(other instanceof FingerprintEntity))
89: {
90: return false;
91: }
92:
93:• return id != null && Objects.equals(id, ((FingerprintEntity)other).getId());
94: }
95:
96: @Override
97: public int hashCode()
98: {
99: return getClass().hashCode();
100: }
101: }