All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mybatisflex.codegen.config.TableConfig Maven / Gradle / Ivy

There is a newer version: 1.10.3
Show newest version
/*
 *  Copyright (c) 2022-2025, Mybatis-Flex ([email protected]).
 *  

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.mybatisflex.codegen.config; import com.mybatisflex.annotation.InsertListener; import com.mybatisflex.annotation.SetListener; import com.mybatisflex.annotation.UpdateListener; import java.io.Serializable; import java.util.HashMap; import java.util.Map; /** * 表的单独设置。 */ @SuppressWarnings({"unused", "UnusedReturnValue"}) public class TableConfig implements Serializable { public static final String ALL_TABLES = "*"; private static final long serialVersionUID = -2568968178699265858L; /** * 数据库的 schema(模式)。 */ private String schema; /** * 表名。 */ private String tableName = ALL_TABLES; /** * 默认为 驼峰属性 转换为 下划线字段。 */ private Boolean camelToUnderline; /** * 监听 entity 的 insert 行为。 */ private Class insertListenerClass; /** * 监听 entity 的 update 行为。 */ private Class updateListenerClass; /** * 监听 entity 的查询数据的 set 行为。 */ private Class setListenerClass; /** * 是否开启 Mapper 生成。 */ private Boolean mapperGenerateEnable = Boolean.TRUE; /** * 对应列的配置。 */ private Map columnConfigMap; public static TableConfig create() { return new TableConfig(); } public String getSchema() { return this.schema; } public TableConfig setSchema(String schema) { this.schema = schema; return this; } public String getTableName() { return this.tableName; } public TableConfig setTableName(String tableName) { this.tableName = tableName; return this; } public Boolean getCamelToUnderline() { return this.camelToUnderline; } public TableConfig setCamelToUnderline(Boolean camelToUnderline) { this.camelToUnderline = camelToUnderline; return this; } public Class getInsertListenerClass() { return this.insertListenerClass; } public TableConfig setInsertListenerClass(Class insertListenerClass) { this.insertListenerClass = insertListenerClass; return this; } public Class getUpdateListenerClass() { return this.updateListenerClass; } public TableConfig setUpdateListenerClass(Class updateListenerClass) { this.updateListenerClass = updateListenerClass; return this; } public Class getSetListenerClass() { return this.setListenerClass; } public TableConfig setSetListenerClass(Class setListenerClass) { this.setListenerClass = setListenerClass; return this; } public Boolean getMapperGenerateEnable() { return this.mapperGenerateEnable; } public TableConfig setMapperGenerateEnable(Boolean mapperGenerateEnable) { this.mapperGenerateEnable = mapperGenerateEnable; return this; } public Map getColumnConfigMap() { return this.columnConfigMap; } public TableConfig setColumnConfigMap(Map columnConfigMap) { this.columnConfigMap = columnConfigMap; return this; } public TableConfig setColumnConfig(ColumnConfig columnConfig) { if (this.columnConfigMap == null) { this.columnConfigMap = new HashMap<>(); } this.columnConfigMap.put(columnConfig.getColumnName(), columnConfig); return this; } protected ColumnConfig getColumnConfig(String columnName) { return this.columnConfigMap == null ? null : this.columnConfigMap.get(columnName); } public static Builder builder() { return new Builder(); } public static final class Builder { private final TableConfig tableConfig; private Builder() { this.tableConfig = new TableConfig(); } public Builder schema(String schema) { this.tableConfig.setSchema(schema); return this; } public Builder tableName(String tableName) { this.tableConfig.setTableName(tableName); return this; } public Builder camelToUnderline(Boolean camelToUnderline) { this.tableConfig.setCamelToUnderline(camelToUnderline); return this; } public Builder insertListenerClass(Class insertListenerClass) { this.tableConfig.setInsertListenerClass(insertListenerClass); return this; } public Builder updateListenerClass(Class updateListenerClass) { this.tableConfig.setUpdateListenerClass(updateListenerClass); return this; } public Builder setListenerClass(Class setListenerClass) { this.tableConfig.setSetListenerClass(setListenerClass); return this; } public Builder mapperGenerateEnable(Boolean mapperGenerateEnable) { this.tableConfig.setMapperGenerateEnable(mapperGenerateEnable); return this; } public Builder columnConfig(ColumnConfig columnConfigMap) { this.tableConfig.setColumnConfig(columnConfigMap); return this; } public TableConfig build() { return this.tableConfig; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy