Skip to content

Commit 9dcffb1

Browse files
Minor auto-refactor code cleanup on a massive scale (#554)
1 parent 1fda962 commit 9dcffb1

File tree

79 files changed

+316
-341
lines changed

Some content is hidden

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

79 files changed

+316
-341
lines changed

SkylineToolsStore/src/org/labkey/skylinetoolsstore/RatingManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public Rating[] getRatingsByToolAllVersions(String toolLsid)
8787
for (SkylineTool tool : tools)
8888
ratings.addAll(Arrays.asList(getRatingsByToolId(tool.getRowId())));
8989
}
90-
return ratings.toArray(new Rating[ratings.size()]);
90+
return ratings.toArray(new Rating[0]);
9191
}
9292

9393
public boolean userLeftRating(String toolLsid, User user)

SkylineToolsStore/src/org/labkey/skylinetoolsstore/SkylineToolsStoreController.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public SkylineToolsStoreController()
129129
}
130130

131131
@RequiresPermission(ReadPermission.class)
132-
public class BeginAction extends SimpleViewAction
132+
public static class BeginAction extends SimpleViewAction<Object>
133133
{
134134
@Override
135135
public ModelAndView getView(Object o, BindException errors) throws Exception
@@ -460,7 +460,7 @@ public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest,
460460
ArrayList<User> toolOwnersUsers = parsedOwners.first;
461461
ArrayList<String> toolOwnersInvalid = parsedOwners.second;
462462

463-
if (toolOwnersInvalid.size() > 0)
463+
if (!toolOwnersInvalid.isEmpty())
464464
{
465465
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
466466
UNKNOWN_USERS + StringUtils.join(toolOwnersInvalid, ", "));
@@ -607,7 +607,7 @@ else if (!getContainer().hasPermission(getUser(), InsertPermission.class))
607607
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "sender", sender);
608608
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "updatetarget", updateTargetString);
609609
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "toolowners", toolOwners);
610-
return new JspView("/org/labkey/skylinetoolsstore/view/SkylineToolsStoreUpload.jsp", null);
610+
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineToolsStoreUpload.jsp", null);
611611
}
612612

613613
@Override
@@ -667,9 +667,9 @@ protected ModelAndView handleRequestInternal(HttpServletRequest httpServletReque
667667
final String ratingIdString = httpServletRequest.getParameter("ratingId");
668668
int ratingId;
669669
try {
670-
ratingId = (ratingIdString != null && !ratingIdString.isEmpty()) ? Integer.parseInt(ratingIdString) : -1;;
670+
ratingId = (ratingIdString != null && !ratingIdString.isEmpty()) ? Integer.parseInt(ratingIdString) : -1;
671671
} catch(Exception e) {
672-
return new JspView("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
672+
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
673673
}
674674
Rating rating = (ratingId < 0) ? null : RatingManager.get().getRatingById(ratingId);
675675
final SkylineTool tool = SkylineToolsStoreManager.get().getTool((toolId >= 0) ? toolId : rating.getToolId());
@@ -679,7 +679,7 @@ protected ModelAndView handleRequestInternal(HttpServletRequest httpServletReque
679679
try {
680680
ratingValue = Integer.parseInt(ratingValueString);
681681
} catch(Exception e) {
682-
return new JspView("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
682+
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
683683
}
684684
final String ratingTitle = httpServletRequest.getParameter("title");
685685
final String review = httpServletRequest.getParameter("review");
@@ -701,7 +701,7 @@ else if (ratingValue < 1 || ratingValue > 5)
701701
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
702702
NO_RATING);
703703
}
704-
else if (review == null || review.length() == 0)
704+
else if (review == null || review.isEmpty())
705705
{
706706
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
707707
NO_REVIEW);
@@ -748,7 +748,7 @@ else if (tool == null || (ratingId >= 0 && rating == null))
748748
if (review != null)
749749
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "formReview", review);
750750

751-
return new JspView("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
751+
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
752752
}
753753

754754
@Override
@@ -813,7 +813,7 @@ public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest,
813813
{
814814
httpServletRequest.setAttribute(BindingResult.MODEL_KEY_PREFIX + "form", INVALID_TOOL_ID + " " + suppTargetString);
815815
httpServletRequest.setAttribute(BindingResult.MODEL_KEY_PREFIX + "supptarget", suppTargetString);
816-
return new JspView("/org/labkey/skylinetoolsstore/view/SkylineToolSupplementUpload.jsp", null);
816+
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineToolSupplementUpload.jsp", null);
817817
}
818818

819819
SkylineTool tool = SkylineToolsStoreManager.get().getTool(suppTarget);
@@ -846,7 +846,7 @@ public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest,
846846
}
847847

848848
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "supptarget", suppTargetString);
849-
return new JspView("/org/labkey/skylinetoolsstore/view/SkylineToolSupplementUpload.jsp", null);
849+
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineToolSupplementUpload.jsp", null);
850850
}
851851

852852
@Override
@@ -902,7 +902,7 @@ public void checkPermissions() throws UnauthorizedException
902902
}
903903

904904
@RequiresLogin
905-
public class DeleteAction extends FormHandlerAction<IdForm>
905+
public static class DeleteAction extends FormHandlerAction<IdForm>
906906
{
907907
@Override
908908
public URLHelper getSuccessURL(IdForm idForm)
@@ -1002,7 +1002,7 @@ public class DeleteLatestAction extends AbstractController implements Permission
10021002
@Override
10031003
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
10041004
{
1005-
Integer id;
1005+
int id;
10061006
try {
10071007
id = Integer.parseInt(httpServletRequest.getParameter("id"));
10081008
}
@@ -1156,7 +1156,7 @@ public void checkPermissions() throws UnauthorizedException
11561156

11571157
@RequiresNoPermission
11581158
@ActionNames("downloadFile")
1159-
public class DownloadToolFileAction extends SimpleViewAction<DownloadFileForm> implements PermissionCheckable
1159+
public static class DownloadToolFileAction extends SimpleViewAction<DownloadFileForm> implements PermissionCheckable
11601160
{
11611161
@Override
11621162
public ModelAndView getView(DownloadFileForm form, BindException errors) throws Exception
@@ -1243,8 +1243,7 @@ public ModelAndView getView(ViewToolDetailsForm form, BindException errors) thro
12431243
_tool = SkylineToolsStoreManager.get().getTool(toolId);
12441244
if (_tool == null)
12451245
{
1246-
StringBuilder msg = new StringBuilder("Could not find tool ").append(" by Id ").append(toolId);
1247-
errors.reject(SpringActionController.ERROR_MSG, msg.toString());
1246+
errors.reject(SpringActionController.ERROR_MSG, "Could not find tool " + " by Id " + toolId);
12481247
return new SimpleErrorView(errors);
12491248
}
12501249
}
@@ -1396,7 +1395,7 @@ public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest,
13961395
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "toolowners", toolOwners);
13971396
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "sender", sender);
13981397
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "updatetarget", updateTargetString);
1399-
return new JspView("/org/labkey/skylinetoolsstore/view/SkylineToolManageOwners.jsp", null);
1398+
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineToolManageOwners.jsp", null);
14001399
}
14011400

14021401
@Override
@@ -1414,7 +1413,7 @@ public class UpdatePropertyAction extends AbstractController implements Permissi
14141413
@Override
14151414
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
14161415
{
1417-
final Integer id = Integer.parseInt(httpServletRequest.getParameter("id"));
1416+
final int id = Integer.parseInt(httpServletRequest.getParameter("id"));
14181417

14191418
final SkylineTool tool = SkylineToolsStoreManager.get().getTool(id);
14201419
if(tool == null)

SkylineToolsStore/src/org/labkey/skylinetoolsstore/SkylineToolsStoreModule.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.labkey.skylinetoolsstore.model.SkylineTool;
3333
import org.labkey.skylinetoolsstore.view.SkylineToolsStoreWebPart;
3434

35-
import java.lang.reflect.InvocationTargetException;
3635
import java.util.ArrayList;
3736
import java.util.Arrays;
3837
import java.util.Collection;
@@ -66,19 +65,21 @@ public boolean hasScripts()
6665
@NotNull
6766
protected Collection<WebPartFactory> createWebPartFactories()
6867
{
69-
return new ArrayList<WebPartFactory>(
70-
Arrays.asList(
71-
new BaseWebPartFactory("Skyline Tool Store") {
68+
return new ArrayList<>(
69+
Arrays.asList(
70+
new BaseWebPartFactory("Skyline Tool Store")
7271
{
73-
addLegacyNames("Skyline Tools Store");
74-
}
75-
@Override
76-
public WebPartView getWebPartView(@NotNull ViewContext portalCtx, Portal.@NotNull WebPart webPart) throws WebPartConfigurationException
77-
{
78-
return new SkylineToolsStoreWebPart();
72+
{
73+
addLegacyNames("Skyline Tools Store");
74+
}
75+
76+
@Override
77+
public WebPartView getWebPartView(@NotNull ViewContext portalCtx, Portal.@NotNull WebPart webPart) throws WebPartConfigurationException
78+
{
79+
return new SkylineToolsStoreWebPart();
80+
}
7981
}
80-
}
81-
));
82+
));
8283
}
8384

8485
@Override

SkylineToolsStore/src/org/labkey/skylinetoolsstore/SkylineToolsStoreSchema.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import org.labkey.api.data.dialect.SqlDialect;
2121
import org.labkey.api.data.TableInfo;
2222

23-
import java.lang.String;
24-
2523
public class SkylineToolsStoreSchema
2624
{
2725
private static final SkylineToolsStoreSchema _instance = new SkylineToolsStoreSchema();

SkylineToolsStore/src/org/labkey/skylinetoolsstore/model/Rating.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ public void setRowId(Integer rowId)
7676

7777
public boolean equals(Object obj)
7878
{
79-
if (!(obj instanceof Rating))
79+
if (!(obj instanceof Rating p))
8080
return false;
81-
Rating p = (Rating)obj;
8281

8382
return Objects.equals(_rating, p.getRating()) &&
8483
Objects.equals(_toolId, p.getToolId()) &&

SkylineToolsStore/src/org/labkey/skylinetoolsstore/model/SkylineTool.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,8 @@ public void setRowId(Integer rowId)
177177

178178
public boolean equals(Object obj)
179179
{
180-
if (!(obj instanceof SkylineTool))
180+
if (!(obj instanceof SkylineTool p))
181181
return false;
182-
SkylineTool p = (SkylineTool)obj;
183182

184183
return Objects.equals(_name, p.getName()) &&
185184
Objects.equals(_authors, p.getAuthors()) &&

lincs/src/org/labkey/lincs/DocImportListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
public class DocImportListener implements ExperimentListener, SkylineDocumentImportListener
3131
{
32-
private static Logger _log = LogManager.getLogger(DocImportListener.class);
32+
private static final Logger _log = LogManager.getLogger(DocImportListener.class);
3333

3434
@Override
3535
public void beforeRunDelete(ExpProtocol protocol, ExpRun run, User user)

lincs/src/org/labkey/lincs/Gct.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
*/
3333
public class Gct
3434
{
35-
private List<GctEntity> _probes;
36-
private Map<String, Integer> _probeIndexMap;
37-
private List<GctEntity> _replicates;
38-
private Map<String, Integer> _replicateIndexMap;
39-
private GctTable<ProbeReplicate> _areaRatios;
35+
private final List<GctEntity> _probes;
36+
private final Map<String, Integer> _probeIndexMap;
37+
private final List<GctEntity> _replicates;
38+
private final Map<String, Integer> _replicateIndexMap;
39+
private final GctTable<ProbeReplicate> _areaRatios;
4040

4141
private List<String> _probeAnnotationNames;
4242
private List<String> _replicateAnnotationNames;
@@ -164,7 +164,7 @@ public List<GctEntity> getSortedReplicates()
164164
// Sort replicates by the value of the det_plate annotation, and then
165165
// by replicate name. For custom GCT, the replicate name is:
166166
// <exp_type>_<plate_number>_<original_replicate_name>
167-
List<GctEntity> sortedReplicates = new ArrayList<GctEntity>(_replicates.size());
167+
List<GctEntity> sortedReplicates = new ArrayList<>(_replicates.size());
168168
sortedReplicates.addAll(_replicates);
169169
sortedReplicates.sort((rep1, rep2) ->
170170
{
@@ -262,7 +262,7 @@ public void setIgnoredProbeAnnotations(Set<String> ignored)
262262
public static class GctEntity
263263
{
264264
private final String _name;
265-
private Map<String, String> _annotations;
265+
private final Map<String, String> _annotations;
266266

267267
public GctEntity(String name)
268268
{
@@ -418,7 +418,7 @@ public String toString()
418418

419419
public interface GctKeyBuilder <T extends GctKey>
420420
{
421-
public T build(String key1, String key2);
421+
T build(String key1, String key2);
422422
}
423423

424424
public static class ProbePlateKeyBuilder implements GctKeyBuilder<ProbeExpTypePlate>
@@ -446,7 +446,7 @@ public GctFileException(String message, Throwable cause)
446446

447447
public static class GctTable <T extends GctKey>
448448
{
449-
private Map<T, String> _map;
449+
private final Map<T, String> _map;
450450
private List<String> _sortedKey2;
451451

452452
public GctTable()

0 commit comments

Comments
 (0)