Skip to content

Commit e83144b

Browse files
Minor auto-refactor code cleanup on a massive scale (#248)
* Minor auto-refactor code cleanup on a massive scale * Remove unnecessary method call
1 parent e31c108 commit e83144b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+182
-205
lines changed

LDK/api-src/org/labkey/api/ldk/table/AbstractTableCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract public class AbstractTableCustomizer implements TableCustomizer
4242
* Rely on DefaultSchema's caching of schema creation, and just track the minimum number of DefaultSchemas to
4343
* resolve the requested collection of target containers
4444
*/
45-
private Map<Container, DefaultSchema> _defaultSchemas = new HashMap<>();
45+
private final Map<Container, DefaultSchema> _defaultSchemas = new HashMap<>();
4646

4747
public UserSchema getUserSchema(AbstractTableInfo ti, String name)
4848
{

LDK/api-src/org/labkey/api/ldk/table/ContainerScopedTable.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public DataIterator getDataIterator(DataIteratorContext context)
242242
final String containerColName = getContainerFilterColumn();
243243
final KeyManager keyManager = new KeyManager();
244244
final SimpleTranslator it = new SimpleTranslator(input, context);
245-
final Map<String, Integer> inputColMap = new HashMap<String, Integer>();
245+
final Map<String, Integer> inputColMap = new HashMap<>();
246246
for (int idx = 1; idx <= input.getColumnCount(); idx++)
247247
{
248248
ColumnInfo col = input.getColumnInfo(idx);
@@ -262,15 +262,15 @@ public DataIterator getDataIterator(DataIteratorContext context)
262262

263263
//set the value of the RowId column
264264
ColumnInfo pseudoPkCol = getColumn(_pseudoPk);
265-
it.addColumn(pseudoPkCol, new Callable<Object>()
265+
it.addColumn(pseudoPkCol, new Callable<>()
266266
{
267267
@Override
268268
public Object call()
269269
{
270270
Container c = null;
271271
if (inputColMap.containsKey(containerColName))
272272
{
273-
String containerId = (String)it.getInputColumnValue(inputColMap.get(containerColName));
273+
String containerId = (String) it.getInputColumnValue(inputColMap.get(containerColName));
274274
if (containerId != null)
275275
c = ContainerManager.getForId(containerId);
276276
}

LDK/api-src/org/labkey/api/ldk/table/CustomPermissionsTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
public class CustomPermissionsTable<SchemaType extends UserSchema> extends SimpleUserSchema.SimpleTable<SchemaType>
3636
{
37-
private Map<Class<? extends Permission>, Class<? extends Permission>> _permMap = new HashMap<>();
37+
private final Map<Class<? extends Permission>, Class<? extends Permission>> _permMap = new HashMap<>();
3838

3939
public CustomPermissionsTable(SchemaType schema, TableInfo table, ContainerFilter cf)
4040
{

LDK/api-src/org/labkey/api/ldk/table/QueryCache.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public class QueryCache
4646
{
4747
private static final Logger _log = LogManager.getLogger(QueryCache.class);
4848

49-
private Map<String, AssayProtocolSchema> _cachedAssaySchemas = new HashMap<>();
50-
private Map<String, UserSchema> _cachedUserSchemas = new HashMap<>();
51-
private Map<String, TableInfo> _cachedQueries = new HashMap<>();
52-
private Map<String, ColumnInfo> _cachedColumns = new HashMap<>();
49+
private final Map<String, AssayProtocolSchema> _cachedAssaySchemas = new HashMap<>();
50+
private final Map<String, UserSchema> _cachedUserSchemas = new HashMap<>();
51+
private final Map<String, TableInfo> _cachedQueries = new HashMap<>();
52+
private final Map<String, ColumnInfo> _cachedColumns = new HashMap<>();
5353

5454
public QueryCache()
5555
{
@@ -104,7 +104,7 @@ public TableInfo getTableInfo(Container targetContainer, User u, String schemaPa
104104

105105
List<QueryException> errors = new ArrayList<>();
106106
TableInfo ti = qd.getTable(errors, true);
107-
if (errors.size() > 0)
107+
if (!errors.isEmpty())
108108
{
109109
_log.error("Unable to create tabbed report item for query: " + schemaPath + "." + queryName + " in " + targetContainer.getPath());
110110
for (QueryException e : errors)

LDK/api-src/org/labkey/api/ldk/table/SimpleButtonConfigFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
*/
4040
public class SimpleButtonConfigFactory implements ButtonConfigFactory
4141
{
42-
private Module _owner;
43-
private String _text;
42+
private final Module _owner;
43+
private final String _text;
4444
private DetailsURL _url = null;
4545
private String _jsHandler = null;
4646
private Integer _insertPosition = null;

LDK/src/org/labkey/ldk/LDKController.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public LDKController()
111111
}
112112

113113
@RequiresPermission(ReadPermission.class)
114-
public class GetNotificationsAction extends ReadOnlyApiAction<Object>
114+
public static class GetNotificationsAction extends ReadOnlyApiAction<Object>
115115
{
116116
@Override
117117
public ApiResponse execute(Object form, BindException errors)
@@ -136,7 +136,7 @@ public ApiResponse execute(Object form, BindException errors)
136136
}
137137

138138
@RequiresPermission(ReadPermission.class)
139-
public class GetFileRootSizesAction extends ReadOnlyApiAction<FileRootSizeForm>
139+
public static class GetFileRootSizesAction extends ReadOnlyApiAction<FileRootSizeForm>
140140
{
141141
@Override
142142
public ApiResponse execute(FileRootSizeForm form, BindException errors) throws Exception
@@ -212,7 +212,7 @@ public void setIncludeFileCounts(Boolean includeFileCounts)
212212
}
213213

214214
@RequiresPermission(AdminOperationsPermission.class)
215-
public class GetSiteNotificationDetailsAction extends ReadOnlyApiAction<Object>
215+
public static class GetSiteNotificationDetailsAction extends ReadOnlyApiAction<Object>
216216
{
217217
@Override
218218
public ApiResponse execute(Object form, BindException errors) throws Exception
@@ -242,7 +242,7 @@ public ApiResponse execute(Object form, BindException errors) throws Exception
242242
}
243243

244244
@RequiresPermission(UpdatePermission.class)
245-
public class UpdateNotificationSubscriptionsAction extends MutatingApiAction<UpdateNotificationSubscriptionsForm>
245+
public static class UpdateNotificationSubscriptionsAction extends MutatingApiAction<UpdateNotificationSubscriptionsForm>
246246
{
247247
@Override
248248
public ApiResponse execute(UpdateNotificationSubscriptionsForm form, BindException errors) throws Exception
@@ -349,7 +349,7 @@ public void setToRemove(Integer[] toRemove)
349349
}
350350

351351
@RequiresPermission(ReadPermission.class)
352-
public class RunNotificationAction extends SimpleViewAction<RunNotificationForm>
352+
public static class RunNotificationAction extends SimpleViewAction<RunNotificationForm>
353353
{
354354
private String _title = null;
355355

@@ -403,7 +403,7 @@ public void addNavTrail(NavTree root)
403403
}
404404

405405
@RequiresPermission(AdminPermission.class)
406-
public class SendNotificationAction extends MutatingApiAction<RunNotificationForm>
406+
public static class SendNotificationAction extends MutatingApiAction<RunNotificationForm>
407407
{
408408
@Override
409409
public ApiResponse execute(RunNotificationForm form, BindException errors) throws Exception
@@ -437,7 +437,7 @@ public ApiResponse execute(RunNotificationForm form, BindException errors) throw
437437
}
438438

439439
@RequiresPermission(ReadPermission.class)
440-
public class ValidateContainerScopedTablesAction extends SimpleViewAction<Object>
440+
public static class ValidateContainerScopedTablesAction extends SimpleViewAction<Object>
441441
{
442442
@Override
443443
public ModelAndView getView(Object form, BindException errors) throws Exception
@@ -459,7 +459,7 @@ public void addNavTrail(NavTree root)
459459
}
460460

461461
@RequiresPermission(AdminPermission.class)
462-
public class GetNotificationSubscriptionsAction extends ReadOnlyApiAction<RunNotificationForm>
462+
public static class GetNotificationSubscriptionsAction extends ReadOnlyApiAction<RunNotificationForm>
463463
{
464464
@Override
465465
public ApiResponse execute(RunNotificationForm form, BindException errors) throws Exception
@@ -509,7 +509,7 @@ public ApiResponse execute(RunNotificationForm form, BindException errors) throw
509509
}
510510

511511
@RequiresPermission(AdminPermission.class)
512-
public class SetNotificationSettingsAction extends MutatingApiAction<NotificationSettingsForm>
512+
public static class SetNotificationSettingsAction extends MutatingApiAction<NotificationSettingsForm>
513513
{
514514
@Override
515515
public ApiResponse execute(NotificationSettingsForm form, BindException errors)
@@ -648,7 +648,7 @@ public Predicate<String> allowBindParameter()
648648

649649

650650
@RequiresPermission(ReadPermission.class)
651-
public class LogMetricAction extends MutatingApiAction<LogMetricForm>
651+
public static class LogMetricAction extends MutatingApiAction<LogMetricForm>
652652
{
653653
@Override
654654
public ApiResponse execute(LogMetricForm form, BindException errors) throws Exception
@@ -822,7 +822,7 @@ public void setKey(String key)
822822
}
823823

824824
@RequiresPermission(ReadPermission.class)
825-
public class UpdateQueryAction extends SimpleViewAction<QueryForm>
825+
public static class UpdateQueryAction extends SimpleViewAction<QueryForm>
826826
{
827827
private QueryForm _form;
828828

@@ -1019,7 +1019,7 @@ public void setTargetContainer(String targetContainer)
10191019
}
10201020

10211021
@RequiresNoPermission
1022-
public class RedirectStartAction extends SimpleViewAction<Object>
1022+
public static class RedirectStartAction extends SimpleViewAction<Object>
10231023
{
10241024
@Override
10251025
public ModelAndView getView(Object form, BindException errors) throws Exception
@@ -1065,7 +1065,7 @@ public void addNavTrail(NavTree root)
10651065
public static final String REDIRECT_URL_PROP = "redirectURL";
10661066

10671067
@RequiresPermission(AdminPermission.class)
1068-
public class SetRedirectUrlAction extends MutatingApiAction<SetRedirectUrlForm>
1068+
public static class SetRedirectUrlAction extends MutatingApiAction<SetRedirectUrlForm>
10691069
{
10701070
@Override
10711071
public ApiResponse execute(SetRedirectUrlForm form, BindException errors) throws Exception
@@ -1100,7 +1100,7 @@ public void setUrl(String url)
11001100
}
11011101

11021102
@RequiresPermission(AdminPermission.class)
1103-
public class GetRedirectUrlAction extends ReadOnlyApiAction<Object>
1103+
public static class GetRedirectUrlAction extends ReadOnlyApiAction<Object>
11041104
{
11051105
@Override
11061106
public ApiResponse execute(Object form, BindException errors) throws Exception
@@ -1111,7 +1111,7 @@ public ApiResponse execute(Object form, BindException errors) throws Exception
11111111

11121112
@RequiresPermission(AdminOperationsPermission.class)
11131113
@AllowedDuringUpgrade
1114-
public class DownloadNaturalizeInstallScriptAction extends ExportAction<Object>
1114+
public static class DownloadNaturalizeInstallScriptAction extends ExportAction<Object>
11151115
{
11161116
@Override
11171117
public void export(Object o, HttpServletResponse response, BindException errors) throws Exception

LDK/src/org/labkey/ldk/LDKServiceImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class LDKServiceImpl extends LDKService
6060
private final Set<NotificationSection> _summaryNotificationSections = new HashSet<>();
6161
private final List<List<String>> _containerScopedTables = new ArrayList<>();
6262
private Boolean _isNaturalizeInstalled = null;
63-
private final Map<String, Map<String, List<ButtonConfigFactory>>> _queryButtons = new CaseInsensitiveHashMap<Map<String, List<ButtonConfigFactory>>>();
63+
private final Map<String, Map<String, List<ButtonConfigFactory>>> _queryButtons = new CaseInsensitiveHashMap<>();
6464
private static final String BACKGROUND_USER_PROPNAME = "BackgroundAdminUser";
6565

6666
public LDKServiceImpl()
@@ -113,7 +113,7 @@ public Map<String, Object> getContainerSizeJson(Container c, User u, boolean inc
113113
//append children
114114
if (includeAllRootTypes)
115115
{
116-
Set<File> paths = new HashSet<File>();
116+
Set<File> paths = new HashSet<>();
117117
for (FileContentService.ContentType type : FileContentService.ContentType.values())
118118
{
119119
File fileRoot = svc.getFileRoot(c, type);
@@ -268,7 +268,7 @@ public List<String> validateContainerScopedTables(boolean onlyReportErrors)
268268
if (ss.exists())
269269
{
270270
messages.add("ERROR: duplicates found in: " + values.get(0) + "." + values.get(1));
271-
ss.forEach(new Selector.ForEachBlock<ResultSet>()
271+
ss.forEach(new Selector.ForEachBlock<>()
272272
{
273273
@Override
274274
public void exec(ResultSet rs) throws SQLException
@@ -334,11 +334,11 @@ public void registerQueryButton(ButtonConfigFactory btn, String schema, String q
334334
{
335335
Map<String, List<ButtonConfigFactory>> schemaMap = _queryButtons.get(schema);
336336
if (schemaMap == null)
337-
schemaMap = new CaseInsensitiveHashMap<List<ButtonConfigFactory>>();
337+
schemaMap = new CaseInsensitiveHashMap<>();
338338

339339
List<ButtonConfigFactory> list = schemaMap.get(query);
340340
if (list == null)
341-
list = new ArrayList<ButtonConfigFactory>();
341+
list = new ArrayList<>();
342342

343343
list.add(btn);
344344

@@ -349,7 +349,7 @@ public void registerQueryButton(ButtonConfigFactory btn, String schema, String q
349349
@Override
350350
public List<ButtonConfigFactory> getQueryButtons(TableInfo ti)
351351
{
352-
List<ButtonConfigFactory> buttons = new ArrayList<ButtonConfigFactory>();
352+
List<ButtonConfigFactory> buttons = new ArrayList<>();
353353

354354
Map<String, List<ButtonConfigFactory>> factories = _queryButtons.get(ti.getPublicSchemaName());
355355
if (factories == null)

LDK/src/org/labkey/ldk/notification/NotificationJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException
4242
_log.info("Trying to run notification: " + _notification.getName());
4343

4444
Set<Container> activeContainers = NotificationServiceImpl.get().getActiveContainers(_notification);
45-
if (activeContainers.size() == 0)
45+
if (activeContainers.isEmpty())
4646
{
4747
_log.info("there are no active containers, skipping");
4848
}

LDK/src/org/labkey/ldk/notification/NotificationServiceImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ public Set<UserPrincipal> getRecipients(Notification n, Container c)
466466
TableSelector ts = new TableSelector(t, Collections.singleton("recipient"), filter, null);
467467
if (ts.getRowCount() > 0)
468468
{
469-
ts.forEach(new TableSelector.ForEachBlock<ResultSet>(){
469+
ts.forEach(new TableSelector.ForEachBlock<>()
470+
{
470471
@Override
471472
public void exec(ResultSet rs) throws SQLException
472473
{
@@ -586,7 +587,7 @@ public void runForContainer(Notification notification, Container c)
586587
}
587588

588589
List<Address> recipients = NotificationServiceImpl.get().getEmails(notification, c);
589-
if (recipients.size() == 0)
590+
if (recipients.isEmpty())
590591
{
591592
_log.info("Notification: " + notification.getName() + " has no recipients, skipping");
592593
return;
@@ -605,7 +606,7 @@ public void runForContainer(Notification notification, Container c)
605606

606607
mail.setFrom(NotificationServiceImpl.get().getReturnEmail(c));
607608
mail.setSubject(notification.getEmailSubject(c));
608-
mail.addRecipients(Message.RecipientType.TO, recipients.toArray(new Address[recipients.size()]));
609+
mail.addRecipients(Message.RecipientType.TO, recipients.toArray(new Address[0]));
609610

610611
MailHelper.send(mail, u, c);
611612
}

0 commit comments

Comments
 (0)