Skip to content

Commit f0b3a04

Browse files
authored
Use typed getters and pattern vars to avoid casting (#57)
1 parent 5acbda8 commit f0b3a04

6 files changed

+9
-7
lines changed

src/org/labkey/remoteapi/assay/GetAssayRunResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void setRun(Run run)
2929
public GetAssayRunResponse(String text, int statusCode, String contentType, JSONObject json)
3030
{
3131
super(text, statusCode, contentType, json);
32-
JSONObject runJson = (JSONObject) json.get("run");
32+
JSONObject runJson = json.getJSONObject("run");
3333
_run = new Run(runJson);
3434
}
3535
}

src/org/labkey/remoteapi/assay/LoadAssayBatchResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class LoadAssayBatchResponse extends CommandResponse
1919
public LoadAssayBatchResponse(String text, int statusCode, String contentType, JSONObject json)
2020
{
2121
super(text, statusCode, contentType, json);
22-
_batch = new Batch((JSONObject) json.get("batch"));
22+
_batch = new Batch(json.getJSONObject("batch"));
2323
}
2424

2525
public Batch getBatch()

src/org/labkey/remoteapi/assay/ProtocolResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ProtocolResponse extends CommandResponse
1010
public ProtocolResponse(String text, int statusCode, String contentType, JSONObject json)
1111
{
1212
super(text, statusCode, contentType, json);
13-
_protocol = new Protocol((JSONObject) json.get("data"));
13+
_protocol = new Protocol(json.getJSONObject("data"));
1414
}
1515

1616
public Protocol getProtocol()

src/org/labkey/remoteapi/assay/SaveAssayBatchResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class SaveAssayBatchResponse extends CommandResponse
2626
public SaveAssayBatchResponse(String text, int statusCode, String contentType, JSONObject json)
2727
{
2828
super(text, statusCode, contentType, json);
29-
_batch = new Batch((JSONObject)json.get("batch"));
29+
_batch = new Batch(json.getJSONObject("batch"));
3030
_assayId = ((Number)json.get("assayId")).intValue();
3131
}
3232

src/org/labkey/remoteapi/domain/ListDomainsResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public ListDomainsResponse(String text, int statusCode, String contentType, JSON
2424
{
2525
super(text, statusCode, contentType, json);
2626
JSONArray domains = json.getJSONArray("data");
27-
for(Object domainJSON: domains)
27+
for (Object domainJSON: domains)
2828
{
2929
_domains.add(new Domain((JSONObject) domainJSON));
3030
}

src/org/labkey/remoteapi/query/SaveRowsCommand.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,10 @@ public JSONObject getJsonObject()
209209
for(Map<String, Object> row : getRows())
210210
{
211211
JSONObject jsonRow;
212-
if(row instanceof JSONObject) //optimization
213-
jsonRow = (JSONObject)row;
212+
if (row instanceof JSONObject jo) //optimization
213+
{
214+
jsonRow = jo;
215+
}
214216
else
215217
{
216218
jsonRow = new JSONObject();

0 commit comments

Comments
 (0)