Package net.hydromatic.sqllogictest.util
Interface ICastable
-
- All Known Subinterfaces:
ISqlTestOperation
- All Known Implementing Classes:
HsqldbExecutor,JdbcExecutor,NoExecutor,PostgresExecutor,SltSqlStatement,SqlSltTestExecutor,SqlTestExecutor,SqlTestQuery
public interface ICastableUtility interface providing some useful casting methods.
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default <T> Tas(PrintStream err, Class<T> clazz, @Nullable String failureMessage)Cast this object ot the specified type.default <T> @Nullable Tas(Class<T> clazz)Cast this object ot the specified type.static <T> @Nullable Tas(Object obj, Class<T> clazz, String s)default voiderror(PrintStream err, String message)Print an error when a cast fails.default <T> booleanis(Class<T> clazz)Check whether this object can be cast to the specified type.default <T> Tto(PrintStream err, Class<T> clazz)Cast this object to the specified type.
-
-
-
Method Detail
-
as
default <T> @Nullable T as(Class<T> clazz)
Cast this object ot the specified type.- Type Parameters:
T- Type of expected object.- Parameters:
clazz- Type to cast to.- Returns:
- An object of type T or null if the cast cannot be performed.
-
error
default void error(PrintStream err, String message)
Print an error when a cast fails.- Parameters:
err- Stream where error is printed.message- Message to print.
-
as
default <T> T as(PrintStream err, Class<T> clazz, @Nullable String failureMessage)
Cast this object ot the specified type.- Type Parameters:
T- Type of expected object.* @param err- Parameters:
clazz- Type to cast to.failureMessage- Message to display if the cast fails.- Returns:
- An object of type T or null if the cast cannot be performed.
-
to
default <T> T to(PrintStream err, Class<T> clazz)
Cast this object to the specified type.- Type Parameters:
T- Type expected. Throws when the cast cannot be performed.- Parameters:
err- Stream where errors are displayed.clazz- Type to cast to.- Returns:
- A non-null object of the specified type.
-
is
default <T> boolean is(Class<T> clazz)
Check whether this object can be cast to the specified type.- Type Parameters:
T- Type expected.- Parameters:
clazz- Type to cast to.- Returns:
- True if the cast can be performed.
-
-