Skip to content

Commit 8abc286

Browse files
Misc code cleanup - improve generics (#230)
1 parent c570a60 commit 8abc286

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@
5757
* Date: 4/2/13
5858
* Time: 2:54 PM
5959
*/
60-
abstract public class AbstractDataDefinedTable extends CustomPermissionsTable
60+
abstract public class AbstractDataDefinedTable<SchemaType extends UserSchema> extends CustomPermissionsTable<SchemaType>
6161
{
6262
protected String _pk;
6363

6464
protected String _filterColumn;
6565
protected String _filterValue;
6666
protected String _valueColumn;
6767

68-
public AbstractDataDefinedTable(UserSchema schema, SchemaTableInfo table, ContainerFilter cf, String filterColumn, String valueColumn, String tableName, String filterValue)
68+
public AbstractDataDefinedTable(SchemaType schema, SchemaTableInfo table, ContainerFilter cf, String filterColumn, String valueColumn, String tableName, String filterValue)
6969
{
7070
super(schema, table, cf);
7171
_filterColumn = filterColumn;
@@ -77,23 +77,23 @@ public AbstractDataDefinedTable(UserSchema schema, SchemaTableInfo table, Contai
7777
}
7878

7979
@Override
80-
public CustomPermissionsTable init()
80+
public CustomPermissionsTable<SchemaType> init()
8181
{
8282
super.init();
8383

8484
ColumnInfo col = getRealTable().getColumn(_filterColumn);
8585
addCondition(col, _filterValue); //enforce only showing rows from this category
8686

8787
List<String> pks = getRealTable().getPkColumnNames();
88-
assert pks.size() > 0;
88+
assert !pks.isEmpty();
8989
_pk = pks.get(0);
9090

9191
var valueCol = getMutableColumn(_valueColumn);
9292
assert valueCol != null;
9393

9494
valueCol.setKeyField(true);
9595
valueCol.setNullable(false);
96-
getMutableColumn(_pk).setKeyField(false);
96+
getMutableColumnOrThrow(_pk).setKeyField(false);
9797

9898
ColumnInfo filterCol = getColumn(_filterColumn);
9999
assert filterCol != null;
@@ -135,7 +135,7 @@ protected class UpdateService extends SimpleQueryUpdateService
135135
{
136136
private final ValuesManager _vm;
137137

138-
public UpdateService(SimpleUserSchema.SimpleTable ti)
138+
public UpdateService(SimpleUserSchema.SimpleTable<SchemaType> ti)
139139
{
140140
super(ti, ti.getRealTable());
141141

@@ -217,8 +217,7 @@ public boolean testIfRowExists(String value)
217217
{
218218
boolean ret = _distinctValues.contains(value);
219219

220-
if (!_distinctValues.contains(value))
221-
_distinctValues.add(value);
220+
_distinctValues.add(value);
222221

223222
return ret;
224223
}

0 commit comments

Comments
 (0)