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

com.landawn.abacus.jdbc.EntityCodeConfig Maven / Gradle / Ivy

There is a newer version: 3.8.5
Show newest version
/*
 * Copyright (c) 2021, Haiyang Li.
 *
 * 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.landawn.abacus.jdbc;

import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.List;
import java.util.function.BiFunction;

import com.landawn.abacus.annotation.Beta;
import com.landawn.abacus.annotation.Type.EnumBy;
import com.landawn.abacus.util.NamingPolicy;
import com.landawn.abacus.util.Tuple.Tuple2;
import com.landawn.abacus.util.Tuple.Tuple3;
import com.landawn.abacus.util.function.QuadFunction;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * A sample, just a sample, not a general configuration required.
 * 
 * EntityCodeConfig ecc = EntityCodeConfig.builder()
 *        .className("User")
 *        .packageName("codes.entity")
 *        .srcDir("./samples")
 *        .fieldNameConverter((tableName, columnName) -> StringUtil.toCamelCase(columnName))
 *        .fieldTypeConverter((tableName, columnName, fieldName, columnClassName) -> ClassUtil.getCanonicalClassName(ClassUtil.forClass(columnClassName)) // columnClassName <- resultSetMetaData.getColumnClassName(columnIndex);
 *                .replace("java.lang.", ""))
 *        .useBoxedType(false)
 *        .readOnlyFields(N.asSet("id"))
 *        .nonUpdatableFields(N.asSet("create_time"))
 *        // .idAnnotationClass(javax.persistence.Id.class)
 *        // .columnAnnotationClass(javax.persistence.Column.class)
 *        // .tableAnnotationClass(javax.persistence.Table.class)
 *        .customizedFields(N.asList(Tuple.of("columnName", "fieldName", java.util.Date.class)))
 *        .customizedFieldDbTypes(N.asList(Tuple.of("fieldName", "List")))
 *        .build();
 * 
* */ @Builder @Data @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) public final class EntityCodeConfig { private String srcDir; private String packageName; private String className; /** * First parameter in the function is table name, 2nd is column name. */ private BiFunction fieldNameConverter; /** * First parameter in the function is table name, 2nd is column name, 3rd is field name, 4th is column class name. */ private QuadFunction fieldTypeConverter; /** * * First parameter in the Tuple is column name, 2nd is field name, 3rd is column class. * */ private List>> customizedFields; /** * First parameter in the Tuple is column name, 2nd is db type. * */ private List> customizedFieldDbTypes; private boolean useBoxedType; private boolean mapBigIntegerToLong; private boolean mapBigDecimalToDouble; private Collection readOnlyFields; private Collection nonUpdatableFields; private Collection idFields; private String idField; private Collection excludedFields; private String additionalFieldsOrLines; private Class tableAnnotationClass; private Class columnAnnotationClass; private Class idAnnotationClass; private boolean chainAccessor; private boolean generateBuilder; private boolean generateCopyMethod; private boolean generateFieldNameTable; private boolean extendFieldNameTableClassName; // private String fieldNameTableClassName; // Always be "NT"; // private List> customizedJsonFields; @Beta private JsonXmlConfig jsonXmlConfig; @Builder @Data @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) public static class JsonXmlConfig { private NamingPolicy namingPolicy; private String ignoredFields; private String dateFormat; private String timeZone; private String numberFormat; private EnumBy enumerated; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy