Skip to content

Commit 4d08d96

Browse files
committed
Go lambda
1 parent 4030b98 commit 4d08d96

File tree

4 files changed

+39
-88
lines changed

4 files changed

+39
-88
lines changed

exist-core/src/main/java/org/exist/client/LabelledBooleanEditor.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ public Component getTableCellEditorComponent(final JTable table, final Object va
5252
chkBox.setHorizontalAlignment(SwingConstants.LEFT);
5353
chkBox.setHorizontalTextPosition(SwingConstants.RIGHT);
5454

55-
chkBox.addActionListener(new ActionListener() {
56-
@Override
57-
public void actionPerformed(final ActionEvent e) {
58-
current = lb.copy(!lb.isSet());
59-
fireEditingStopped(); //notify that editing is done!
60-
}
55+
chkBox.addActionListener(e -> {
56+
current = lb.copy(!lb.isSet());
57+
fireEditingStopped(); //notify that editing is done!
6158
});
6259

6360
return chkBox;

exist-core/src/main/java/org/exist/client/security/EditPropertiesDialog.java

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -232,45 +232,25 @@ private void initComponents() {
232232
lblSizeValue = new javax.swing.JLabel();
233233

234234
miInsertAceBefore.setText("Insert ACE before...");
235-
miInsertAceBefore.addActionListener(new java.awt.event.ActionListener() {
236-
public void actionPerformed(java.awt.event.ActionEvent evt) {
237-
miInsertAceBeforeActionPerformed(evt);
238-
}
239-
});
235+
miInsertAceBefore.addActionListener(evt -> miInsertAceBeforeActionPerformed(evt));
240236
pmAcl.add(miInsertAceBefore);
241237

242238
miInsertAceAfter.setText("Insert ACE after...");
243-
miInsertAceAfter.addActionListener(new java.awt.event.ActionListener() {
244-
public void actionPerformed(java.awt.event.ActionEvent evt) {
245-
miInsertAceAfterActionPerformed(evt);
246-
}
247-
});
239+
miInsertAceAfter.addActionListener(evt -> miInsertAceAfterActionPerformed(evt));
248240
pmAcl.add(miInsertAceAfter);
249241
pmAcl.add(jSeparator3);
250242

251243
miMoveUp.setText("Move ACE up");
252-
miMoveUp.addActionListener(new java.awt.event.ActionListener() {
253-
public void actionPerformed(java.awt.event.ActionEvent evt) {
254-
miMoveUpActionPerformed(evt);
255-
}
256-
});
244+
miMoveUp.addActionListener(evt -> miMoveUpActionPerformed(evt));
257245
pmAcl.add(miMoveUp);
258246

259247
miMoveDown.setText("Move ACE down");
260-
miMoveDown.addActionListener(new java.awt.event.ActionListener() {
261-
public void actionPerformed(java.awt.event.ActionEvent evt) {
262-
miMoveDownActionPerformed(evt);
263-
}
264-
});
248+
miMoveDown.addActionListener(evt -> miMoveDownActionPerformed(evt));
265249
pmAcl.add(miMoveDown);
266250
pmAcl.add(jSeparator4);
267251

268252
miRemoveAce.setText("Remove ACE");
269-
miRemoveAce.addActionListener(new java.awt.event.ActionListener() {
270-
public void actionPerformed(java.awt.event.ActionEvent evt) {
271-
miRemoveAceActionPerformed(evt);
272-
}
273-
});
253+
miRemoveAce.addActionListener(evt -> miRemoveAceActionPerformed(evt));
274254
pmAcl.add(miRemoveAce);
275255

276256
jTextArea1.setColumns(20);
@@ -305,18 +285,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
305285
lblGroupValue.setText("<group>");
306286

307287
btnChangeOwner.setText("...");
308-
btnChangeOwner.addActionListener(new java.awt.event.ActionListener() {
309-
public void actionPerformed(java.awt.event.ActionEvent evt) {
310-
btnChangeOwnerActionPerformed(evt);
311-
}
312-
});
288+
btnChangeOwner.addActionListener(evt -> btnChangeOwnerActionPerformed(evt));
313289

314290
btnChangeGroup.setText("...");
315-
btnChangeGroup.addActionListener(new java.awt.event.ActionListener() {
316-
public void actionPerformed(java.awt.event.ActionEvent evt) {
317-
btnChangeGroupActionPerformed(evt);
318-
}
319-
});
291+
btnChangeGroup.addActionListener(evt -> btnChangeGroupActionPerformed(evt));
320292

321293
tblBasePermissions.setModel(getBasicPermissionsTableModel());
322294
tblBasePermissions.setRowSelectionAllowed(false);
@@ -336,25 +308,13 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
336308
jScrollPane3.setViewportView(tblAcl);
337309

338310
btnSave.setText("Save");
339-
btnSave.addActionListener(new java.awt.event.ActionListener() {
340-
public void actionPerformed(java.awt.event.ActionEvent evt) {
341-
btnSaveActionPerformed(evt);
342-
}
343-
});
311+
btnSave.addActionListener(evt -> btnSaveActionPerformed(evt));
344312

345313
btnClose.setText("Close");
346-
btnClose.addActionListener(new java.awt.event.ActionListener() {
347-
public void actionPerformed(java.awt.event.ActionEvent evt) {
348-
btnCloseActionPerformed(evt);
349-
}
350-
});
314+
btnClose.addActionListener(evt -> btnCloseActionPerformed(evt));
351315

352316
btnAddAce.setText("Add Access Control Entry...");
353-
btnAddAce.addActionListener(new java.awt.event.ActionListener() {
354-
public void actionPerformed(java.awt.event.ActionEvent evt) {
355-
btnAddAceActionPerformed(evt);
356-
}
357-
});
317+
btnAddAce.addActionListener(evt -> btnAddAceActionPerformed(evt));
358318

359319
lblDigest.setText("Digest:");
360320

exist-core/src/main/java/org/exist/storage/BackupSystemTask.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,17 @@ public void purgeZipFiles() throws IOException {
149149
int entriesNumber = entriesPaths.size();
150150
int numberOfEntriesToBeDeleted = entriesNumber - zipFilesMax + 1;
151151

152-
Comparator<Path> timestampComparator = new Comparator<Path>() {
153-
public int compare(Path path1, Path path2) {
154-
int result = 0;
155-
156-
try {
157-
result = Files.getLastModifiedTime(path1).compareTo(Files.getLastModifiedTime(path2));
158-
} catch (IOException e) {
159-
LOG.error("Cannot compare files by timestamp: " + path1 + ", " + path2, e);
160-
}
161-
162-
return result;
163-
}
164-
};
152+
Comparator<Path> timestampComparator = (path1, path2) -> {
153+
int result = 0;
154+
155+
try {
156+
result = Files.getLastModifiedTime(path1).compareTo(Files.getLastModifiedTime(path2));
157+
} catch (IOException e) {
158+
LOG.error("Cannot compare files by timestamp: " + path1 + ", " + path2, e);
159+
}
160+
161+
return result;
162+
};
165163

166164
if (numberOfEntriesToBeDeleted > 0) {
167165
entriesPaths.stream().sorted(timestampComparator).limit(numberOfEntriesToBeDeleted).forEach(path -> {

exist-core/src/main/java/org/exist/storage/structural/NativeStructuralIndexWorker.java

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -551,12 +551,10 @@ protected List<QName> getQNamesForDoc(DocumentImpl doc) {
551551
final byte[] toKey = computeDocKey(doc.getDocId() + 1);
552552
final IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(toKey));
553553
try(final ManagedLock<ReentrantLock> btreeLock = index.lockManager.acquireBtreeWriteLock(index.btree.getLockName())) {
554-
index.btree.query(query, new BTreeCallback() {
555-
public boolean indexInfo(Value value, long pointer) throws TerminatedException {
556-
final QName qname = readQName(value.getData());
557-
qnames.add(qname);
558-
return true;
559-
}
554+
index.btree.query(query, (value, pointer) -> {
555+
final QName qname = readQName(value.getData());
556+
qnames.add(qname);
557+
return true;
560558
});
561559
} catch (final LockException e) {
562560
NativeStructuralIndex.LOG.warn("Failed to lock structural index: " + e.getMessage(), e);
@@ -610,20 +608,18 @@ public Occurrences[] scanIndex(XQueryContext context, DocumentSet docs, NodeSet
610608
final IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(toKey));
611609

612610
try(final ManagedLock<ReentrantLock> btreeLock = index.lockManager.acquireBtreeReadLock(index.btree.getLockName())) {
613-
index.btree.query(query, new BTreeCallback() {
614-
public boolean indexInfo(Value value, long pointer) throws TerminatedException {
615-
Occurrences oc = occurrences.get(name);
616-
if (oc == null) {
617-
oc = new Occurrences(name);
618-
occurrences.put(name, oc);
619-
oc.addDocument(doc);
620-
oc.addOccurrences(1);
621-
} else {
622-
oc.addOccurrences(1);
623-
oc.addDocument(doc);
624-
}
625-
return true;
611+
index.btree.query(query, (value, pointer) -> {
612+
Occurrences oc = occurrences.get(name);
613+
if (oc == null) {
614+
oc = new Occurrences(name);
615+
occurrences.put(name, oc);
616+
oc.addDocument(doc);
617+
oc.addOccurrences(1);
618+
} else {
619+
oc.addOccurrences(1);
620+
oc.addDocument(doc);
626621
}
622+
return true;
627623
});
628624
} catch (final LockException e) {
629625
NativeStructuralIndex.LOG.warn("Failed to lock structural index: " + e.getMessage(), e);

0 commit comments

Comments
 (0)