1. Project Clover database Wed Nov 12 2025 05:07:35 UTC
  2. Package guru.mikelue.foxglove.setting

File DataSettingInfo.java

 

Code metrics

0
0
0
1
79
11
0
-
-
0
-

Classes

Class Line # Actions
DataSettingInfo 13 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

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