| Class | Line # | Actions | |||||
|---|---|---|---|---|---|---|---|
| DataSettingInfo | 14 | 0 | - | 0 | 0 |
| 1 | package guru.mikelue.foxglove.setting; | |
| 2 | ||
| 3 | import java.sql.JDBCType; | |
| 4 | import java.util.Optional; | |
| 5 | import java.util.function.Supplier; | |
| 6 | ||
| 7 | import guru.mikelue.foxglove.ColumnMeta; | |
| 8 | import guru.mikelue.foxglove.functional.ColumnMatcher; | |
| 9 | import guru.mikelue.foxglove.jdbc.CustomStatementSetter; | |
| 10 | ||
| 11 | /** | |
| 12 | * This interface defines the methods used by engine of data generating. | |
| 13 | */ | |
| 14 | public interface DataSettingInfo { | |
| 15 | /** | |
| 16 | * Gets the default number of rows for generated data. | |
| 17 | * | |
| 18 | * <p> | |
| 19 | * | |
| 20 | * This number of rows is used when: | |
| 21 | * | |
| 22 | * <ul> | |
| 23 | * <li>No specific number of rows is defined by {@link guru.mikelue.foxglove.TableFacet}</li> | |
| 24 | * </ul> | |
| 25 | * | |
| 26 | * The default value is {@value DefaultSetting#DEFAULT_NUMBER_OF_ROWS}. | |
| 27 | * | |
| 28 | * @return The default number of rows for generated data | |
| 29 | */ | |
| 30 | int getDefaultNumberOfRows(); | |
| 31 | ||
| 32 | /** | |
| 33 | * Resolves the {@link Supplier} for the given column metadata. | |
| 34 | * | |
| 35 | * The priority of resolution is: | |
| 36 | * | |
| 37 | * <ol> | |
| 38 | * <li>Column matcher configured by {@link DataSetting#columnMatcher(ColumnMatcher)}</li> | |
| 39 | * <li>Type name configured by {@link DataSetting#givenType(String)}</li> | |
| 40 | * <li>JDBC type configured by {@link DataSetting#givenType(JDBCType)}</li> | |
| 41 | * </ol> | |
| 42 | * | |
| 43 | * @param <T> The type of value supplied by the resolved {@link Supplier} | |
| 44 | * @param columnMeta The metadata of column used to resolve {@link Supplier} | |
| 45 | * | |
| 46 | * @return The resolved {@link Supplier} or empty | |
| 47 | */ | |
| 48 | <T> Optional<Supplier<T>> resolveSupplier(ColumnMeta columnMeta); | |
| 49 | ||
| 50 | /** | |
| 51 | * Gets whether or not to generate value automatically | |
| 52 | * by the given properties of a column. | |
| 53 | * | |
| 54 | * Additionally, the {@link DataSetting#excludeWhen(ColumnMatcher)} also affects this behavior. | |
| 55 | * | |
| 56 | * <p> | |
| 57 | * The default properties to generate value automatically: | |
| 58 | * | |
| 59 | * <ul> | |
| 60 | * <li>{@link ColumnMeta.Property#NULLABLE}</li> | |
| 61 | * <li>{@link ColumnMeta.Property#DEFAULT_VALUE}</li> | |
| 62 | * </ul> | |
| 63 | * | |
| 64 | * <p> | |
| 65 | * The conditions used by this method will gives {@code true} for a column: | |
| 66 | * <ol> | |
| 67 | * <li>Not-excluded by {@link DataSetting#excludeWhen(ColumnMatcher)}</li> | |
| 68 | * <li>Matches any customized matching by {@link DataSetting#columnMatcher(ColumnMatcher)}</li> | |
| 69 | * <li>Not-excluded by {@link ColumnMeta#properties()}</li> | |
| 70 | * <li>Matches type by {@link DataSetting#givenType(String)}</li> | |
| 71 | * <li>Matches type by {@link DataSetting#givenType(JDBCType)}</li> | |
| 72 | * <li>Not-excluded by not supported {@link JDBCType}s</li> | |
| 73 | * </ol> | |
| 74 | * | |
| 75 | * @param column The metadata of a column | |
| 76 | * | |
| 77 | * @return Whether or not to generate value automatically | |
| 78 | */ | |
| 79 | boolean isAutoGenerating(ColumnMeta column); | |
| 80 | ||
| 81 | /** | |
| 82 | * Gets the {@link CustomStatementSetter} for the given column metadata. | |
| 83 | * | |
| 84 | * @param meta The metadata of a column | |
| 85 | * | |
| 86 | * @return The {@link CustomStatementSetter} for the given column metadata or empty | |
| 87 | */ | |
| 88 | Optional<CustomStatementSetter<?>> getStatementSetter(ColumnMeta meta); | |
| 89 | } |