-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommonImpl.java
58 lines (48 loc) · 1.33 KB
/
CommonImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package kp.e_j_b;
import java.util.logging.Level;
import java.util.logging.Logger;
import jakarta.inject.Inject;
import kp.util.Tools;
/**
* The abstract implementation of the {@link Common} interface.
*
*/
public abstract class CommonImpl implements Common {
private int previous = 0;
@SuppressWarnings("java:S6813") // switch off Sonarqube rule 'Avoid field dependency injection'
@Inject
private Logger logger;
/**
* The constructor.
*/
protected CommonImpl() {
super();
}
/**
* {@inheritDoc} Implemented.
*
*/
@Override
public String check(String stamp) {
final String message = String.format("implementation[%s], stamp[%s]", this.getClass().getSimpleName(), stamp);
if (logger.isLoggable(Level.INFO)) {
logger.info(String.format("check(): %s", message));
}
return message;
}
/**
* {@inheritDoc} Implemented.
*
*/
@Override
public String change(String stamp, int number) {
final String message = String.format(
"stamp[%s], current number[%s], previous number[%s], current equals previous[%b], object hash code[%s]",
stamp, number, previous, number == previous, Tools.hashCodeFormatted(this));
previous = number;
if (logger.isLoggable(Level.INFO)) {
logger.info(String.format("change():%n\t%s", message));
}
return message;
}
}