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

com.easy.query.core.proxy.AbstractValueObjectProxyEntity Maven / Gradle / Ivy

There is a newer version: 2.0.106
Show newest version
package com.easy.query.core.proxy;

import com.easy.query.core.annotation.Nullable;
import com.easy.query.core.expression.parser.core.available.TableAvailable;
import com.easy.query.core.proxy.columns.SQLAnyColumn;
import com.easy.query.core.proxy.columns.SQLBooleanColumn;
import com.easy.query.core.proxy.columns.SQLDateTimeColumn;
import com.easy.query.core.proxy.columns.SQLNavigateColumn;
import com.easy.query.core.proxy.columns.SQLNumberColumn;
import com.easy.query.core.proxy.columns.SQLStringColumn;
import com.easy.query.core.proxy.columns.impl.SQLAnyColumnImpl;
import com.easy.query.core.proxy.columns.impl.SQLBooleanColumnImpl;
import com.easy.query.core.proxy.columns.impl.SQLDateTimeColumnImpl;
import com.easy.query.core.proxy.columns.impl.SQLNavigateColumnImpl;
import com.easy.query.core.proxy.columns.impl.SQLNumberColumnImpl;
import com.easy.query.core.proxy.columns.impl.SQLStringColumnImpl;
import com.easy.query.core.proxy.columns.types.SQLAnyTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLBigDecimalTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLBooleanTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLByteTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLDateTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLDoubleTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLFloatTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLIntegerTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLLocalDateTimeTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLLocalDateTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLLocalTimeTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLLongTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLShortTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLStringTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLTimeTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLTimestampTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLUUIDTypeColumn;
import com.easy.query.core.proxy.columns.types.SQLUtilDateTypeColumn;
import com.easy.query.core.proxy.columns.types.impl.SQLAnyTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLBigDecimalTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLBooleanTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLByteTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLDateTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLDoubleTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLFloatTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLIntegerTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLLocalDateTimeTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLLocalDateTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLLocalTimeTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLLongTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLShortTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLStringTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLTimeTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLTimestampTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLUUIDTypeColumnImpl;
import com.easy.query.core.proxy.columns.types.impl.SQLUtilDateTypeColumnImpl;
import com.easy.query.core.proxy.core.EntitySQLContext;
import com.easy.query.core.proxy.impl.SQLColumnImpl;
import com.easy.query.core.util.EasyObjectUtil;

/**
 * create time 2023/11/7 20:07
 * 文件说明
 *
 * @author xuejiaming
 */
public abstract class AbstractValueObjectProxyEntity implements SQLColumn, ValueObjectProxyEntity {
    private final EntitySQLContext entitySQLContext;
    private final TableAvailable table;
    private final String parentProperty;
    private Class propType;
    private TProxy tProxy;

    public AbstractValueObjectProxyEntity(EntitySQLContext entitySQLContext, TableAvailable table, String property) {
        this.entitySQLContext = entitySQLContext;

        this.table = table;
        this.parentProperty = property;
        this.propType = Object.class;
    }

    @Override
    public void _setProxy(TProxy tProxy) {
        this.tProxy = tProxy;
    }

    @Override
    public TableAvailable getTable() {
        return table;
    }

    @Override
    public String getValue() {
        return parentProperty;
    }

    @Override
    public EntitySQLContext getEntitySQLContext() {
        return entitySQLContext;
    }

    protected  N __cast(T original) {
        return EasyObjectUtil.typeCastNullable(original);
    }

    protected , TVProperty> TPropertyProxy getValueObject(TPropertyProxy propertyProxy) {
        propertyProxy._setProxy(castChain());
        return propertyProxy;
    }

    protected  SQLColumn get(String property, Class propType) {
        SQLColumn column = new SQLColumnImpl<>(entitySQLContext, table, getValueProperty(property), propType);
        column._setProxy(castChain());
        return column;
    }

    protected  SQLDateTimeColumn getDateTimeColumn(String property, @Nullable Class propType) {
        SQLDateTimeColumn column =  new SQLDateTimeColumnImpl<>(entitySQLContext, table, getValueProperty(property), propType);
        column._setProxy(castChain());
        return column;
    }

    protected  SQLNumberColumn getNumberColumn(String property, @Nullable Class propType) {
        SQLNumberColumn column = new SQLNumberColumnImpl<>(entitySQLContext, table, getValueProperty(property), propType);
        column._setProxy(castChain());
        return column;
    }

    protected  SQLStringColumn getStringColumn(String property, @Nullable Class propType) {
        SQLStringColumn column =  new SQLStringColumnImpl<>(entitySQLContext, table, getValueProperty(property), propType);
        column._setProxy(castChain());
        return column;
    }

    protected  SQLBooleanColumn getBooleanColumn(String property, @Nullable Class propType) {
        SQLBooleanColumn column = new SQLBooleanColumnImpl<>(entitySQLContext, table, getValueProperty(property), propType);
        column._setProxy(castChain());
        return column;
    }

    protected  SQLAnyColumn getAnyColumn(String property, @Nullable Class propType) {
        SQLAnyColumn column = new SQLAnyColumnImpl<>(entitySQLContext, table, getValueProperty(property), propType);
        column._setProxy(castChain());
        return column;
    }

    protected String getValueProperty(String property) {
        return parentProperty + "." + property;
    }

    protected  SQLNavigateColumn getNavigate(String property, Class propType) {
        SQLNavigateColumn column = new SQLNavigateColumnImpl<>(entitySQLContext, table, property, propType);
        column._setProxy(castChain());
        return column;
    }


    protected  SQLAnyTypeColumn getAnyTypeColumn(String property, @Nullable Class propType) {
        SQLAnyTypeColumn column = new SQLAnyTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property), propType);
        column._setProxy(castChain());
        return column;
    }

    protected SQLBigDecimalTypeColumn getBigDecimalTypeColumn(String property) {
        SQLBigDecimalTypeColumn column = new SQLBigDecimalTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLBooleanTypeColumn getBooleanTypeColumn(String property) {
        SQLBooleanTypeColumn column = new SQLBooleanTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLByteTypeColumn getByteTypeColumn(String property) {
        SQLByteTypeColumn column =  new SQLByteTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLDateTypeColumn getSQLDateTypeColumn(String property) {
        SQLDateTypeColumn column = new SQLDateTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLDoubleTypeColumn getDoubleTypeColumn(String property) {
        SQLDoubleTypeColumn column = new SQLDoubleTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLFloatTypeColumn getFloatTypeColumn(String property) {
        SQLFloatTypeColumn column = new SQLFloatTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLIntegerTypeColumn getIntegerTypeColumn(String property) {
        SQLIntegerTypeColumn column = new SQLIntegerTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLLocalDateTimeTypeColumn getLocalDateTimeTypeColumn(String property) {
        SQLLocalDateTimeTypeColumn column =  new SQLLocalDateTimeTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLLocalDateTypeColumn getLocalDateTypeColumn(String property) {
        SQLLocalDateTypeColumn column = new SQLLocalDateTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLLocalTimeTypeColumn getLocalTimeTypeColumn(String property) {
        SQLLocalTimeTypeColumn column = new SQLLocalTimeTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLLongTypeColumn getLongTypeColumn(String property) {
        SQLLongTypeColumn column = new SQLLongTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLShortTypeColumn getShortTypeColumn(String property) {
        SQLShortTypeColumn column = new SQLShortTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLStringTypeColumn getStringTypeColumn(String property) {
        SQLStringTypeColumn column = new SQLStringTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLTimestampTypeColumn getTimestampTypeColumn(String property) {
        SQLTimestampTypeColumn column =  new SQLTimestampTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLTimeTypeColumn getTimeTypeColumn(String property) {
        SQLTimeTypeColumn column = new SQLTimeTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLUtilDateTypeColumn getUtilDateTypeColumn(String property) {
        SQLUtilDateTypeColumn column = new SQLUtilDateTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    protected SQLUUIDTypeColumn getUUIDTypeColumn(String property) {
        SQLUUIDTypeColumn column = new SQLUUIDTypeColumnImpl<>(entitySQLContext, table, getValueProperty(property));
        column._setProxy(castChain());
        return column;
    }

    @Override
    public Class getPropertyType() {
        return propType;
    }

    @Override
    public  void _setPropertyType(Class clazz) {
        this.propType = clazz;
    }

    @Override
    public  SQLColumn asAnyType(Class clazz) {
        _setPropertyType(clazz);
        return EasyObjectUtil.typeCastNullable(this);
    }

    @Override
    public TProxy castChain() {
        return tProxy;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy