1+ package dev .mhh .cloner .api .builder ;
2+
3+ import dev .mhh .cloner .api .CloneConfiguration ;
4+
5+ import java .io .Serializable ;
6+ import java .util .List ;
7+ import java .util .function .Consumer ;
8+ import java .util .function .Function ;
9+
10+ /**
11+ * Builder for configuring how a root table and its related tables
12+ * should be cloned, including join relationships and nested sub-tables.
13+ *
14+ * <p>The configuration forms a tree where each table may define
15+ * joins to related tables using different join strategies.</p>
16+ */
17+ public interface CloneConfigurationBuilder <T extends Serializable > extends CloneConfigurationSubBuilder <T > {
18+
19+ /**
20+ * Defines the name of the column used to identify rows with foreign key joins
21+ *
22+ * @param columnName defaults it "id"
23+ * @return this builder for fluent chaining
24+ */
25+ CloneConfigurationBuilder <T > idColumnName (final String columnName );
26+
27+ /**
28+ * Defines the PostgreSQL schema to use for the clone.
29+ * @param schema defaults to "public"
30+ * @return this builder for fluent chaining
31+ */
32+ CloneConfigurationBuilder <T > schema (final String schema );
33+
34+ /**
35+ * Function that is used to convert the id columns given as T to a database string that can be used in a where.
36+ * Some defaults already exist, so this is only needed if T is a custom type
37+ * @param idsToDatabaseStringFunction the function to convert
38+ * @return this builder for fluent chaining
39+ */
40+ CloneConfigurationBuilder <T > idsToDatabaseStringFunction (final Function <T , String > idsToDatabaseStringFunction );
41+
42+ @ Override
43+ CloneConfigurationBuilder <T > joinByJoinTableForeignKey (String tableName , String foreignKey , Consumer <CloneConfigurationSubBuilder <T >> subTables );
44+
45+ @ Override
46+ default CloneConfigurationBuilder <T > joinByJoinTableForeignKey (String tableName , String foreignKey ) {
47+ return joinByJoinTableForeignKey (tableName , foreignKey , _ -> {});
48+ }
49+
50+ @ Override
51+ CloneConfigurationBuilder <T > joinByMainTableForeignKey (String tableName , String foreignKey , Consumer <CloneConfigurationSubBuilder <T >> subTables );
52+
53+ @ Override
54+ default CloneConfigurationBuilder <T > joinByMainTableForeignKey (String tableName , String foreignKey ) {
55+ return joinByMainTableForeignKey (tableName , foreignKey , _ -> {});
56+ }
57+
58+ @ Override
59+ CloneConfigurationBuilder <T > joinByMatchingColumns (String tableName , String mainTableColumn , String joinedTableColumn , Consumer <CloneConfigurationSubBuilder <T >> subTables );
60+
61+ @ Override
62+ default CloneConfigurationBuilder <T > joinByMatchingColumns (String tableName , String mainTableColumn , String joinedTableColumn ) {
63+ return joinByMatchingColumns (tableName , mainTableColumn , joinedTableColumn , _ -> {});
64+ }
65+
66+ /**
67+ * @return the fully configured clone configuration
68+ */
69+ CloneConfiguration <T > build ();
70+ }
0 commit comments