Skip to content

Commit 7bc1792

Browse files
Update to Kernsoftware 3.19.2 and modernize with Java 17 features (#107)
* Initial plan * Update Kernsoftware version to 3.19.2 in all modules Co-authored-by: ChristianHoesel <[email protected]> * Refactor: Use Java 17 features (records, pattern matching, var, lambdas) Co-authored-by: ChristianHoesel <[email protected]> * Refactor: Add more Java 17 features (switch expressions, more lambdas) Co-authored-by: ChristianHoesel <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: ChristianHoesel <[email protected]>
1 parent 199e4d4 commit 7bc1792

File tree

13 files changed

+54
-167
lines changed

13 files changed

+54
-167
lines changed

de.bitctrl.dav.toolset.appanalyzer/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ nerzswe {
1919
//--------------------------------------------------------------------
2020
// Abhängigkeiten
2121
//--------------------------------------------------------------------
22-
String kernsoftware_version = '3.19.0'
22+
String kernsoftware_version = '3.19.2'
2323

2424
dependencies {
2525
implementation "de.bsvrz.dav:de.bsvrz.dav.daf:$kernsoftware_version"

de.bitctrl.dav.toolset.appanalyzer/src/main/java/de/bitctrl/dav/toolset/appanalyzer/Exporter.java

Lines changed: 9 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -58,74 +58,15 @@
5858
*/
5959
public class Exporter extends Thread {
6060

61-
private static class SummaryKey {
62-
63-
private final String rolle;
64-
private final SystemObjectType type;
65-
private final AttributeGroup atg;
66-
private final Aspect asp;
67-
68-
SummaryKey(final String rolle, final SystemObjectType type, final AttributeGroup atg, final Aspect asp) {
69-
this.rolle = rolle;
70-
this.type = type;
71-
this.atg = atg;
72-
this.asp = asp;
73-
}
74-
75-
@Override
76-
public int hashCode() {
77-
final int prime = 31;
78-
int result = 1;
79-
result = (prime * result) + ((asp == null) ? 0 : asp.hashCode());
80-
result = (prime * result) + ((atg == null) ? 0 : atg.hashCode());
81-
result = (prime * result) + ((rolle == null) ? 0 : rolle.hashCode());
82-
result = (prime * result) + ((type == null) ? 0 : type.hashCode());
83-
return result;
84-
}
85-
86-
@Override
87-
public boolean equals(final Object obj) {
88-
if (this == obj) {
89-
return true;
90-
}
91-
if (obj == null) {
92-
return false;
93-
}
94-
if (!(obj instanceof SummaryKey)) {
95-
return false;
96-
}
97-
final SummaryKey other = (SummaryKey) obj;
98-
if (asp == null) {
99-
if (other.asp != null) {
100-
return false;
101-
}
102-
} else if (!asp.equals(other.asp)) {
103-
return false;
104-
}
105-
if (atg == null) {
106-
if (other.atg != null) {
107-
return false;
108-
}
109-
} else if (!atg.equals(other.atg)) {
110-
return false;
111-
}
112-
if (rolle == null) {
113-
if (other.rolle != null) {
114-
return false;
115-
}
116-
} else if (!rolle.equals(other.rolle)) {
117-
return false;
118-
}
119-
if (type == null) {
120-
if (other.type != null) {
121-
return false;
122-
}
123-
} else if (!type.equals(other.type)) {
124-
return false;
125-
}
126-
return true;
127-
}
128-
61+
/**
62+
* Key for summarizing export data by role, type, attribute group and aspect.
63+
*
64+
* @param rolle the role
65+
* @param type the system object type
66+
* @param atg the attribute group
67+
* @param asp the aspect
68+
*/
69+
private record SummaryKey(String rolle, SystemObjectType type, AttributeGroup atg, Aspect asp) {
12970
}
13071

13172
private final Set<SystemObject> exportApplications = new HashSet<>();

de.bitctrl.dav.toolset.appanalyzer/src/main/java/de/bitctrl/dav/toolset/appanalyzer/MainView.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,12 @@ public void removeListDataListener(final ListDataListener l) {
9494

9595
final JButton exportButton = new JButton("Exportiere Anmeldungen");
9696
getContentPane().add(exportButton, BorderLayout.SOUTH);
97-
exportButton.addActionListener(new ActionListener() {
98-
99-
@Override
100-
public void actionPerformed(final ActionEvent e) {
101-
final JFileChooser fileChooser = new JFileChooser();
102-
if (fileChooser.showOpenDialog(MainView.this) == JFileChooser.APPROVE_OPTION) {
103-
final Exporter exporter = new Exporter(dav, applicationList, fileChooser.getSelectedFile(),
104-
onlySummary);
105-
exporter.start();
106-
}
97+
exportButton.addActionListener(e -> {
98+
var fileChooser = new JFileChooser();
99+
if (fileChooser.showOpenDialog(MainView.this) == JFileChooser.APPROVE_OPTION) {
100+
var exporter = new Exporter(dav, applicationList, fileChooser.getSelectedFile(),
101+
onlySummary);
102+
exporter.start();
107103
}
108104
});
109105
}

de.bitctrl.dav.toolset.archivcheck/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ nerzswe {
1818
//--------------------------------------------------------------------
1919
// Abhängigkeiten
2020
//--------------------------------------------------------------------
21-
String kernsoftware_version = '3.19.0'
21+
String kernsoftware_version = '3.19.2'
2222

2323
dependencies {
2424
implementation "de.bsvrz.dav:de.bsvrz.dav.daf:$kernsoftware_version"

de.bitctrl.dav.toolset.archivcheck/src/main/java/de/bitctrl/dav/toolset/archivcheck/AkkumulationKey.java

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,48 +26,11 @@
2626

2727
package de.bitctrl.dav.toolset.archivcheck;
2828

29-
import java.util.Objects;
30-
31-
class AkkumulationKey {
32-
33-
private Object atg;
34-
private Object asp;
35-
36-
AkkumulationKey(final Object atg, final Object aspect) {
37-
this.atg = atg;
38-
this.asp = aspect;
39-
}
40-
41-
@Override
42-
public boolean equals(final Object obj) {
43-
44-
if (this == obj) {
45-
return true;
46-
}
47-
if (obj instanceof AkkumulationKey) {
48-
final AkkumulationKey akkKey = (AkkumulationKey) obj;
49-
return Objects.equals(asp, akkKey.asp) && Objects.equals(atg, akkKey.atg);
50-
}
51-
52-
return false;
53-
}
54-
55-
public Object getAsp() {
56-
return asp;
57-
}
58-
59-
public Object getAtg() {
60-
return atg;
61-
}
62-
63-
@Override
64-
public int hashCode() {
65-
return Objects.hash(asp, atg);
66-
}
67-
68-
@Override
69-
public String toString() {
70-
return "AkkumulationKey [atg=" + atg + ", asp=" + asp + "]";
71-
}
72-
29+
/**
30+
* Key for accumulating archive data by attribute group and aspect.
31+
*
32+
* @param atg the attribute group
33+
* @param asp the aspect
34+
*/
35+
record AkkumulationKey(Object atg, Object asp) {
7336
}

de.bitctrl.dav.toolset.archivcheck/src/main/java/de/bitctrl/dav/toolset/archivcheck/ArchivSizer.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private static class ResultSet {
7272
}
7373

7474
private boolean isValid() {
75-
return (this.object instanceof SystemObject) && ((SystemObject) this.object).isValid();
75+
return (this.object instanceof SystemObject sysObj) && sysObj.isValid();
7676
}
7777

7878
private boolean isMissed() {
@@ -113,12 +113,12 @@ public void initialize(final ClientDavInterface connection) throws Exception {
113113

114114
model = connection.getDataModel();
115115

116-
final File startDir = new File(baseDir);
116+
var startDir = new File(baseDir);
117117
if (!startDir.isDirectory()) {
118118
throw new InvalidArgumentException(baseDir + " ist kein Verzeichnis");
119119
}
120120

121-
final File[] listFiles = startDir.listFiles();
121+
var listFiles = startDir.listFiles();
122122
if (listFiles != null) {
123123
for (final File child : listFiles) {
124124
if (child.getName().startsWith(ArchivSizer.OBJ_DIR_PREFIX)) {
@@ -127,12 +127,7 @@ public void initialize(final ClientDavInterface connection) throws Exception {
127127
}
128128
}
129129

130-
Collections.sort(results, new Comparator<ResultSet>() {
131-
@Override
132-
public int compare(final ResultSet o1, final ResultSet o2) {
133-
return ((Long) o2.size.getSize()).compareTo(o1.size.getSize());
134-
}
135-
});
130+
Collections.sort(results, (o1, o2) -> ((Long) o2.size.getSize()).compareTo(o1.size.getSize()));
136131

137132
try (PrintWriter output = new PrintWriter(new FileWriter(outputFile))) {
138133
printheader(output);
@@ -153,7 +148,7 @@ public int compare(final ResultSet o1, final ResultSet o2) {
153148

154149
private void printResult(final PrintWriter output, final ResultSet set) {
155150

156-
final StringBuffer result = new StringBuffer(200);
151+
var result = new StringBuilder(200);
157152
if (set.isMissed()) {
158153
result.append('-');
159154
} else if (!set.isValid()) {
@@ -191,12 +186,12 @@ private void printheader(final PrintWriter output) {
191186
}
192187

193188
private void printAkkResult(final PrintWriter output, final AkkumulationKey key, final SizeSet value) {
194-
final StringBuffer result = new StringBuffer(200);
189+
var result = new StringBuilder(200);
195190
result.append(value.getSetCount());
196191
result.append(';');
197-
result.append(key.getAtg());
192+
result.append(key.atg());
198193
result.append(';');
199-
result.append(key.getAsp());
194+
result.append(key.asp());
200195
result.append(';');
201196
result.append(value.getSize());
202197
result.append(';');

de.bitctrl.dav.toolset.kblister/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ nerzswe {
1919
//--------------------------------------------------------------------
2020
// Abhängigkeiten
2121
//--------------------------------------------------------------------
22-
String kernsoftware_version = '3.19.0'
22+
String kernsoftware_version = '3.19.2'
2323

2424
dependencies {
2525
implementation "de.bsvrz.dav:de.bsvrz.dav.daf:$kernsoftware_version"

de.bitctrl.dav.toolset.kblister/src/main/java/de/bitctrl/dav/toolset/kblister/KbLister.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,21 @@ public void initialize(final ClientDavInterface connection) throws Exception {
7171

7272
final DataModel model = connection.getDataModel();
7373

74-
Set<ConfigurationArea> allKbSortedPerPid = new TreeSet<>(new Comparator<ConfigurationArea>() {
75-
76-
@Override
77-
public int compare(final ConfigurationArea o1, final ConfigurationArea o2) {
78-
return o1.getPid().compareTo(o2.getPid());
79-
}
80-
});
74+
var allKbSortedPerPid = new TreeSet<ConfigurationArea>(
75+
(o1, o2) -> o1.getPid().compareTo(o2.getPid()));
8176

8277
for (SystemObject obj : model.getTypeTypeObject().getElements()) {
83-
final SystemObjectType type = (SystemObjectType) obj;
84-
final TreeSet<ConfigurationArea> kbs = new TreeSet<>(new PidComparator());
78+
if (obj instanceof SystemObjectType type) {
79+
var kbs = new TreeSet<ConfigurationArea>(new PidComparator());
8580

86-
for (SystemObject element : type.getElements()) {
87-
final ConfigurationArea configurationArea = element.getConfigurationArea();
88-
kbs.add(configurationArea);
89-
allKbSortedPerPid.add(configurationArea);
90-
}
81+
for (SystemObject element : type.getElements()) {
82+
var configurationArea = element.getConfigurationArea();
83+
kbs.add(configurationArea);
84+
allKbSortedPerPid.add(configurationArea);
85+
}
9186

92-
results.put(type, kbs);
87+
results.put(type, kbs);
88+
}
9389
}
9490

9591
for (Entry<SystemObjectType, Set<ConfigurationArea>> result : results.entrySet()) {

de.bitctrl.dav.toolset.parameter.klassufd/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ nerzswe {
1818
//--------------------------------------------------------------------
1919
// Abhängigkeiten
2020
//--------------------------------------------------------------------
21-
String kernsoftware_version = '3.19.0'
21+
String kernsoftware_version = '3.19.2'
2222

2323
dependencies {
2424
implementation "de.bsvrz.dav:de.bsvrz.dav.daf:$kernsoftware_version"

de.bitctrl.dav.toolset.parameter.klassufd/src/main/java/de/bitctrl/dav/toolset/parameter/klassufd/UfdsSensorType.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,11 @@ public String getAttName() {
8787
* @return das Array
8888
*/
8989
public double[][] getDefaultStufen() {
90-
switch (this) {
91-
case NI:
92-
return UfdsSensorType.NI_STUFEN;
93-
case SW:
94-
return UfdsSensorType.SW_STUFEN;
95-
case WFD:
96-
return UfdsSensorType.WFD_STUFEN;
97-
default:
98-
return UfdsSensorType.EMPTY;
99-
}
90+
return switch (this) {
91+
case NI -> NI_STUFEN;
92+
case SW -> SW_STUFEN;
93+
case WFD -> WFD_STUFEN;
94+
default -> EMPTY;
95+
};
10096
}
10197
}

0 commit comments

Comments
 (0)