Skip to content

Commit 9a165b5

Browse files
authored
Merge pull request #3631 from dizzzz/improvements/more_misc_improvements
Another round of codebase improvements
2 parents 669851f + f34633f commit 9a165b5

File tree

34 files changed

+129
-131
lines changed

34 files changed

+129
-131
lines changed

exist-core/src/main/java/org/exist/backup/Main.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ public static void process(final ParsedArguments arguments) {
156156

157157
final boolean guiMode = getBool(arguments, guiArg);
158158
final boolean quiet = getBool(arguments, quietArg);
159-
Optional.ofNullable(arguments.get(optionArg)).ifPresent(options -> {
160-
options.forEach(properties::setProperty);
161-
});
159+
Optional.ofNullable(arguments.get(optionArg)).ifPresent(options -> options.forEach(properties::setProperty));
162160

163161
properties.setProperty(USER_PROP, arguments.get(userArg));
164162
final String optionPass = arguments.get(passwordArg);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ private synchronized void type(final KeyEvent e) {
652652
shell.setCaretPosition(doc.getLength());
653653
}
654654
}
655-
if (e.paramString().indexOf(Messages.getString("ClientFrame.93")) > Constants.STRING_NOT_FOUND) { //$NON-NLS-1$
655+
if (e.paramString().contains(Messages.getString("ClientFrame.93"))) { //$NON-NLS-1$
656656
if (shell.getCaretPosition() <= commandStart) {
657657
e.consume();
658658
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,10 @@ protected String toXMLString()
676676
{
677677
if(parameters.size() > 0)
678678
{
679-
Iterator iterator = parameters.keySet().iterator();
680-
while(iterator.hasNext())
681-
{
682-
final String name = (String) iterator.next();
679+
for (Object o : parameters.keySet()) {
680+
final String name = (String) o;
683681
final String value = parameters.getProperty(name);
684-
682+
685683
trigger.append("<parameter name=\"");
686684
trigger.append(name);
687685
trigger.append("\" value=\"");

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,7 @@ private void setupComponents() throws XMLDBException {
220220
item = new JMenuItem(Messages.getString("DocumentView.17"), KeyEvent.VK_S); //$NON-NLS-1$
221221
item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
222222
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
223-
item.addActionListener(e -> {
224-
save();
225-
});
223+
item.addActionListener(e -> save());
226224
fileMenu.add(item);
227225
/*
228226
// Refresh

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ private void initComponents() {
190190
tblBasePermissions = new javax.swing.JTable();
191191
if (applyTo.size() > 1) {
192192
tblBasePermissions.setDefaultRenderer(Boolean.class, new TristateCheckBoxTableCellRenderer<Boolean>(bool -> Tuple(null, TristateState.fromBoolean(bool))));
193-
tblBasePermissions.setDefaultEditor(Boolean.class, new TristateCheckboxTableCellEditor<Boolean>(bool -> Tuple(null, TristateState.fromBoolean(bool)), state -> TristateState.toBoolean(state._2)));
193+
tblBasePermissions.setDefaultEditor(Boolean.class, new TristateCheckboxTableCellEditor<>(bool -> Tuple(null, TristateState.fromBoolean(bool)), state -> TristateState.toBoolean(state._2)));
194194
tblBasePermissions.setDefaultRenderer(LabelledBoolean.class, new TristateCheckBoxTableCellRenderer<LabelledBoolean>(labelledBool -> Tuple(labelledBool.getLabel(), TristateState.fromBoolean(labelledBool.isSet()))));
195-
tblBasePermissions.setDefaultEditor(LabelledBoolean.class, new TristateCheckboxTableCellEditor<LabelledBoolean>(labelledBool -> Tuple(labelledBool.getLabel(), TristateState.fromBoolean(labelledBool.isSet())), state -> new LabelledBoolean(state._1, TristateState.toBoolean(state._2))));
195+
tblBasePermissions.setDefaultEditor(LabelledBoolean.class, new TristateCheckboxTableCellEditor<>(labelledBool -> Tuple(labelledBool.getLabel(), TristateState.fromBoolean(labelledBool.isSet())), state -> new LabelledBoolean(state._1, TristateState.toBoolean(state._2))));
196196
} else {
197197
tblBasePermissions.setDefaultRenderer(LabelledBoolean.class, new CheckboxTableCellRenderer<LabelledBoolean>(labelledBoolean -> Tuple(labelledBoolean.getLabel(), labelledBoolean.isSet())));
198-
tblBasePermissions.setDefaultEditor(LabelledBoolean.class, new CheckboxTableCellEditor<LabelledBoolean>(labelledBoolean -> Tuple(labelledBoolean.getLabel(), labelledBoolean.isSet()), state -> new LabelledBoolean(state._1, state._2)));
198+
tblBasePermissions.setDefaultEditor(LabelledBoolean.class, new CheckboxTableCellEditor<>(labelledBoolean -> Tuple(labelledBoolean.getLabel(), labelledBoolean.isSet()), state -> new LabelledBoolean(state._1, state._2)));
199199
}
200200
lblAccessControlList = new javax.swing.JLabel();
201201
jSeparator1 = new javax.swing.JSeparator();
@@ -214,25 +214,25 @@ private void initComponents() {
214214
lblSizeValue = new javax.swing.JLabel();
215215

216216
miInsertAceBefore.setText("Insert ACE before...");
217-
miInsertAceBefore.addActionListener(evt -> miInsertAceBeforeActionPerformed(evt));
217+
miInsertAceBefore.addActionListener(this::miInsertAceBeforeActionPerformed);
218218
pmAcl.add(miInsertAceBefore);
219219

220220
miInsertAceAfter.setText("Insert ACE after...");
221-
miInsertAceAfter.addActionListener(evt -> miInsertAceAfterActionPerformed(evt));
221+
miInsertAceAfter.addActionListener(this::miInsertAceAfterActionPerformed);
222222
pmAcl.add(miInsertAceAfter);
223223
pmAcl.add(jSeparator3);
224224

225225
miMoveUp.setText("Move ACE up");
226-
miMoveUp.addActionListener(evt -> miMoveUpActionPerformed(evt));
226+
miMoveUp.addActionListener(this::miMoveUpActionPerformed);
227227
pmAcl.add(miMoveUp);
228228

229229
miMoveDown.setText("Move ACE down");
230-
miMoveDown.addActionListener(evt -> miMoveDownActionPerformed(evt));
230+
miMoveDown.addActionListener(this::miMoveDownActionPerformed);
231231
pmAcl.add(miMoveDown);
232232
pmAcl.add(jSeparator4);
233233

234234
miRemoveAce.setText("Remove ACE");
235-
miRemoveAce.addActionListener(evt -> miRemoveAceActionPerformed(evt));
235+
miRemoveAce.addActionListener(this::miRemoveAceActionPerformed);
236236
pmAcl.add(miRemoveAce);
237237

238238
jTextArea1.setColumns(20);
@@ -267,10 +267,10 @@ private void initComponents() {
267267
lblGroupValue.setText("<group>");
268268

269269
btnChangeOwner.setText("...");
270-
btnChangeOwner.addActionListener(evt -> btnChangeOwnerActionPerformed(evt));
270+
btnChangeOwner.addActionListener(this::btnChangeOwnerActionPerformed);
271271

272272
btnChangeGroup.setText("...");
273-
btnChangeGroup.addActionListener(evt -> btnChangeGroupActionPerformed(evt));
273+
btnChangeGroup.addActionListener(this::btnChangeGroupActionPerformed);
274274

275275
tblBasePermissions.setModel(getBasicPermissionsTableModel());
276276
tblBasePermissions.setRowSelectionAllowed(false);
@@ -290,13 +290,13 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
290290
jScrollPane3.setViewportView(tblAcl);
291291

292292
btnSave.setText("Save");
293-
btnSave.addActionListener(evt -> btnSaveActionPerformed(evt));
293+
btnSave.addActionListener(this::btnSaveActionPerformed);
294294

295295
btnClose.setText("Close");
296-
btnClose.addActionListener(evt -> btnCloseActionPerformed(evt));
296+
btnClose.addActionListener(this::btnCloseActionPerformed);
297297

298298
btnAddAce.setText("Add Access Control Entry...");
299-
btnAddAce.addActionListener(evt -> btnAddAceActionPerformed(evt));
299+
btnAddAce.addActionListener(this::btnAddAceActionPerformed);
300300

301301
lblDigest.setText("Digest:");
302302

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private boolean isValidUsername(final String username) {
166166

167167
private ComboBoxModel<String> getUsernameModel() {
168168
if(usernameModel == null) {
169-
usernameModel = new DefaultComboBoxModel<String>();
169+
usernameModel = new DefaultComboBoxModel<>();
170170
usernameModel.addElement("");
171171
for(final String username : allUsernames) {
172172
usernameModel.addElement(username);

exist-core/src/main/java/org/exist/http/Descriptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public boolean allowSource(String path) {
293293
path = path.replace('\\', '/');
294294

295295
//does the path match the <allow-source><xquery path=""/></allow-source> path
296-
if ((s.equals(path)) || (path.indexOf(s) > -1)) {
296+
if ((s.equals(path)) || (path.contains(s))) {
297297
//yes, return true
298298
return (true);
299299
}

exist-core/src/main/java/org/exist/http/filter/GuestFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
9090
LOG.info("username [" + username + "]");
9191
LOG.info("requestURI [" + requestURI + "]");
9292

93-
if (requestURI.indexOf("/webdav/") >= 0) {
93+
if (requestURI.contains("/webdav/")) {
9494
if (username != null && username.equalsIgnoreCase("guest")) {
9595
LOG.info("Permission denied to : " + requestURI);
9696
httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);

exist-core/src/main/java/org/exist/http/filter/PathFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
9999
LOG.info("queryString = [" + queryString + "]");
100100
LOG.info("method = [" + httpServletRequest.getMethod() + "]");
101101

102-
if ((queryString != null && queryString.indexOf("_query=") >= 0) && filterNames.contains(TEST_GET_QUERY)) {
102+
if ((queryString != null && queryString.contains("_query=")) && filterNames.contains(TEST_GET_QUERY)) {
103103
LOG.info(TEST_GET_QUERY + " met");
104104
conditionMet = true;
105-
} else if (requestURI != null && requestURI.indexOf("/rest/") >= 0 && filterNames.contains(TEST_REST)) {
105+
} else if (requestURI != null && requestURI.contains("/rest/") && filterNames.contains(TEST_REST)) {
106106
conditionMet = true;
107107
LOG.info(TEST_REST + " met");
108108
} else if (httpServletRequest.getMethod().equalsIgnoreCase("PUT") && filterNames.contains(TEST_PUT)) {

exist-core/src/main/java/org/exist/repo/Deployment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public Optional<String> deploy(final DBBroker broker, final Txn transaction, fin
459459

460460
if (!errors.isEmpty()) {
461461
throw new PackageException("Deployment incomplete, " + errors.size() + " issues found: " +
462-
errors.stream().collect(Collectors.joining("; ")));
462+
String.join("; ", errors));
463463
}
464464
return Optional.ofNullable(targetCollection.getCollectionPath());
465465
}

0 commit comments

Comments
 (0)