Skip to content

Commit a55aac6

Browse files
committed
Use switch
1 parent cfde338 commit a55aac6

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

api/src/org/labkey/api/exp/PropertyColumn.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ public void setParentIsObjectId(boolean id)
211211
@Override
212212
public SQLFragment getValueSql(String tableAlias)
213213
{
214-
String cast = getPropertySqlCastType();
215214
SQLFragment sql = new SQLFragment("(SELECT ");
216215
if (isMvIndicatorColumn())
217216
{
@@ -232,6 +231,8 @@ else if (_pd.getPropertyType() == PropertyType.BOOLEAN)
232231
else
233232
sql.append(getTableAlias(tableAlias)).append(".ObjectId");
234233
sql.append(")");
234+
235+
String cast = getPropertySqlCastType();
235236
if (null != cast)
236237
{
237238
sql.insert(0, "CAST(");
@@ -262,23 +263,21 @@ static private String getPropertyCol(@NotNull PropertyDescriptor pd)
262263
};
263264
}
264265

265-
private String getPropertySqlCastType()
266+
private @Nullable String getPropertySqlCastType()
266267
{
267268
if (isMvIndicatorColumn())
268269
return null;
269-
PropertyType pt = _pd.getPropertyType();
270-
if (PropertyType.DOUBLE == pt || PropertyType.DATE_TIME == pt || PropertyType.DECIMAL == pt || PropertyType.FLOAT == pt)
271-
return null;
272-
else if (PropertyType.TIME == pt)
273-
return "TIME";
274-
else if (PropertyType.DATE == pt)
275-
return "DATE";
276-
else if (PropertyType.INTEGER == pt)
277-
return "INT";
278-
else if (PropertyType.BOOLEAN == pt)
279-
return getParentTable().getSqlDialect().getBooleanDataType();
280-
else
281-
return getParentTable().getSqlDialect().getSqlTypeName(JdbcType.VARCHAR) + "(" + PropertyStorageSpec.DEFAULT_SIZE + ")";
270+
271+
return switch (_pd.getPropertyType())
272+
{
273+
case DOUBLE, DATE_TIME, DECIMAL, FLOAT -> null;
274+
case TIME -> "TIME";
275+
case DATE -> "DATE";
276+
case INTEGER -> "INT";
277+
case BOOLEAN -> getParentTable().getSqlDialect().getBooleanDataType();
278+
case null, default -> getParentTable().getSqlDialect().getSqlTypeName(JdbcType.VARCHAR) +
279+
"(" + PropertyStorageSpec.DEFAULT_SIZE + ")";
280+
};
282281
}
283282

284283
public PropertyDescriptor getPropertyDescriptor()

0 commit comments

Comments
 (0)