| Class | Line # | Actions | |||||
|---|---|---|---|---|---|---|---|
| ColumnMatchers | 13 | 4 | 0% | 4 | 8 |
| 1 | package guru.mikelue.foxglove.functional; | |
| 2 | ||
| 3 | import java.sql.JDBCType; | |
| 4 | ||
| 5 | import guru.mikelue.foxglove.ColumnMeta; | |
| 6 | import guru.mikelue.foxglove.setting.DataSetting; | |
| 7 | ||
| 8 | /** | |
| 9 | * Built-in column matchers. | |
| 10 | * | |
| 11 | * @see DataSetting#columnMatcher(ColumnMatcher) | |
| 12 | */ | |
| 13 | public interface ColumnMatchers { | |
| 14 | /** | |
| 15 | * Builds a matcher for matching name(case incensitive) of a column. | |
| 16 | * | |
| 17 | * @param columnName The column name to be checked | |
| 18 | * | |
| 19 | * @return A matcher for that column name | |
| 20 | */ | |
| 21 | 0 | static ColumnMatcher forName(String columnName) |
| 22 | { | |
| 23 | 0 | return c -> c.name().equalsIgnoreCase(columnName); |
| 24 | }; | |
| 25 | ||
| 26 | /** | |
| 27 | * Builds a matcher for a column that has a specific property. | |
| 28 | * | |
| 29 | * @param checkedProperty The property to be checked | |
| 30 | * | |
| 31 | * @return A matcher for a column has that property | |
| 32 | */ | |
| 33 | 0 | static ColumnMatcher hasProperty(ColumnMeta.Property checkedProperty) |
| 34 | { | |
| 35 | 0 | return c -> c.properties().contains(checkedProperty); |
| 36 | }; | |
| 37 | ||
| 38 | /** | |
| 39 | * Builds a matcher for matching a type of JDBC. | |
| 40 | * | |
| 41 | * @param targetType The target type of JDBC | |
| 42 | * | |
| 43 | * @return A matcher for that JDBC type | |
| 44 | */ | |
| 45 | 0 | static ColumnMatcher forJdbcType(JDBCType targetType) |
| 46 | { | |
| 47 | 0 | return c -> c.jdbcType().equals(targetType); |
| 48 | }; | |
| 49 | ||
| 50 | /** | |
| 51 | * Builds a matcher for matching type name(case incensitive) of {@link ColumnMeta}. | |
| 52 | * | |
| 53 | * @param typeName The type to be checked | |
| 54 | * | |
| 55 | * @return A matcher for that type name | |
| 56 | */ | |
| 57 | 0 | static ColumnMatcher forTypeName(String typeName) |
| 58 | { | |
| 59 | 0 | return c -> c.typeName().equalsIgnoreCase(typeName); |
| 60 | }; | |
| 61 | } |