${database.allClassCopyright}package ${glPackageCIQ};
#set ($myClassName = "${myConditionInlineQueryClassName}")
#set ($myCQClassName = "${myBaseConditionQueryClassName}")

import org.seasar.dbflute.cbean.*;
import org.seasar.dbflute.cbean.ckey.*;
import org.seasar.dbflute.cbean.coption.ConditionOption;
import org.seasar.dbflute.cbean.cvalue.ConditionValue;
import org.seasar.dbflute.cbean.sqlclause.SqlClause;
import org.seasar.dbflute.exception.IllegalConditionBeanOperationException;
import ${glPackageCB}.*;
import ${glPackageBaseCQ}.*;
import ${glPackageCQ}.*;

/**
 * The condition-query for in-line of ${table.name}.
 * @author ${database.classAuthor}
 */
public class ${myClassName} extends ${myAbstractBaseConditionQueryClassName} {

    // ===================================================================================
    //                                                                           Attribute
    //                                                                           =========
    protected ${myCQClassName} _myCQ;

    // ===================================================================================
    //                                                                         Constructor
    //                                                                         ===========
    public ${myClassName}(ConditionQuery childQuery, SqlClause sqlClause
                        , String aliasName, int nestLevel, ${myCQClassName} myCQ) {
        super(childQuery, sqlClause, aliasName, nestLevel);
        _myCQ = myCQ;
        _foreignPropertyName = _myCQ.getForeignPropertyName(); // accept foreign property name
        _relationPath = _myCQ.getRelationPath(); // accept relation path
    }

    // ===================================================================================
    //                                                             Override about Register
    //                                                             =======================
    @Override
    protected void reflectRelationOnUnionQuery(ConditionQuery baseQueryAsSuper, ConditionQuery unionQueryAsSuper) {
        String msg = "InlineQuery must not need UNION method: " + baseQueryAsSuper + " : " + unionQueryAsSuper;
        throw new IllegalConditionBeanOperationException(msg);
    }

    @Override
    protected void setupConditionValueAndRegisterWhereClause(ConditionKey k, Object v, ConditionValue cv, String col) {
        regIQ(k, v, cv, col);
    }

    @Override
    protected void setupConditionValueAndRegisterWhereClause(ConditionKey k, Object v, ConditionValue cv, String col, ConditionOption op) {
        regIQ(k, v, cv, col, op);
    }

    @Override
    protected void registerWhereClause(String whereClause) {
        registerInlineWhereClause(whereClause);
    }

    @Override
    protected String getInScopeSubQueryRealColumnName(String columnName) {
        if (_onClauseInline) {
            String msg = "Sorry! InScopeSubQuery of on-clause is unavailable";
            throw new IllegalConditionBeanOperationException(msg);
        }
        return _onClauseInline ? getRealAliasName() + "." + columnName : columnName;
    }

    @Override
    protected void registerExistsSubQuery(ConditionQuery subQuery, String columnName, String relatedColumnName, String propertyName) {
        String msg = "Sorry! ExistsSubQuery at in-line view is unavailable. So please use InScopeSubQyery.";
        throw new IllegalConditionBeanOperationException(msg);
    }

    // ===================================================================================
    //                                                                Override about Query
    //                                                                ====================
#foreach ($col in $table.columns)
#set ($tmpJavaName = "${col.JavaName}")
#set ($tmpUncapitalisedJavaName = "${col.UncapitalisedJavaName}")
    protected ConditionValue getCValue${tmpJavaName}() { return _myCQ.get${tmpJavaName}(); }
#if (${col.isJavaNativeStringObject()})
#if (${col.isSingleKeyForeignKey()} && !${col.foreignKey.hasFixedCondition()})
#set ($relatedCQClassName = "${col.foreignKey.foreignTableExtendedConditionQueryClassName}")
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_InScopeSubQuery_${col.foreignKey.foreignPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_InScopeSubQuery_${col.foreignKey.foreignPropertyNameInitCap}")
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { return _myCQ.keep${subQueryPropertyNameInitCap}(sq); }
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryKeepMapGeneric = "String, ${relatedCQClassName}")
#if (${referrer.isOneToOne()})
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_InScopeSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_InScopeSubQuery_${referrer.ReferrerPropertyNameInitCapAsOne}")
#else
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_InScopeSubQuery_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_InScopeSubQuery_${referrer.ReferrerPropertyNameInitCap}")
#end
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { return _myCQ.keep${subQueryPropertyNameInitCap}(sq); }
#end
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryKeepMapGeneric = "String, ${relatedCQClassName}")
#if (${referrer.isOneToOne()})
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_NotInScopeSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_NotInScopeSubQuery_${referrer.ReferrerPropertyNameInitCapAsOne}")
#else
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_NotInScopeSubQuery_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_NotInScopeSubQuery_${referrer.ReferrerPropertyNameInitCap}")
#end
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { return _myCQ.keep${subQueryPropertyNameInitCap}(sq); }
#end
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryKeepMapGeneric = "String, ${relatedCQClassName}")
#if (${referrer.isOneToOne()})
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_ExistsSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_ExistsSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#else
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_ExistsSubQuery_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_ExistsSubQuery_${referrer.referrerPropertyNameInitCap}")
#end
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { throwIICBOE("ExistsSubQuery"); return null; }
#end
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryKeepMapGeneric = "String, ${relatedCQClassName}")
#if (${referrer.isOneToOne()})
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_NotExistsSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_NotExistsSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#else
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_NotExistsSubQuery_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_NotExistsSubQuery_${referrer.referrerPropertyNameInitCap}")
#end
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { throwIICBOE("NotExistsSubQuery"); return null; }
#end
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#if (!${referrer.isOneToOne()})
#set ($relatedCBClassName = "${referrer.referrerTableExtendedConditionBeanClassName}")
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_SpecifyDerivedReferrer_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_SpecifyDerivedReferrer_${referrer.referrerPropertyNameInitCap}")
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { throwIICBOE("(Specify)DerivedReferrer"); return null; }
#end
#end
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#if (!${referrer.isOneToOne()})
#set ($relatedCBClassName = "${referrer.referrerTableExtendedConditionBeanClassName}")
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_QueryDerivedReferrer_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_QueryDerivedReferrer_${referrer.referrerPropertyNameInitCap}")
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { throwIICBOE("(Query)DerivedReferrer"); return null; }
    public String keep${subQueryPropertyNameInitCap}Parameter(Object pv)
    { throwIICBOE("(Query)DerivedReferrer"); return null; }
#end
#end
#end
#end
#if (${col.isJavaNativeNumberObject()})
#if (${col.isSingleKeyForeignKey()} && !${col.foreignKey.hasFixedCondition()})
#set ($relatedCQClassName = "${col.foreignKey.foreignTableExtendedConditionQueryClassName}")
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_InScopeSubQuery_${col.foreignKey.foreignPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_InScopeSubQuery_${col.foreignKey.foreignPropertyNameInitCap}")
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { return _myCQ.keep${subQueryPropertyNameInitCap}(sq); }
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryKeepMapGeneric = "String, ${relatedCQClassName}")
#if (${referrer.isOneToOne()})
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_InScopeSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_InScopeSubQuery_${referrer.ReferrerPropertyNameInitCapAsOne}")
#else
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_InScopeSubQuery_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_InScopeSubQuery_${referrer.ReferrerPropertyNameInitCap}")
#end
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { return _myCQ.keep${subQueryPropertyNameInitCap}(sq); }
#end
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryKeepMapGeneric = "String, ${relatedCQClassName}")
#if (${referrer.isOneToOne()})
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_NotInScopeSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_NotInScopeSubQuery_${referrer.ReferrerPropertyNameInitCapAsOne}")
#else
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_NotInScopeSubQuery_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_NotInScopeSubQuery_${referrer.ReferrerPropertyNameInitCap}")
#end
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { return _myCQ.keep${subQueryPropertyNameInitCap}(sq); }
#end
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryKeepMapGeneric = "String, ${relatedCQClassName}")
#if (${referrer.isOneToOne()})
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_ExistsSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_ExistsSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#else
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_ExistsSubQuery_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_ExistsSubQuery_${referrer.referrerPropertyNameInitCap}")
#end
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { throwIICBOE("ExistsSubQuery"); return null; }
#end
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryKeepMapGeneric = "String, ${relatedCQClassName}")
#if (${referrer.isOneToOne()})
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_NotExistsSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_NotExistsSubQuery_${referrer.referrerPropertyNameInitCapAsOne}")
#else
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_NotExistsSubQuery_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_NotExistsSubQuery_${referrer.referrerPropertyNameInitCap}")
#end
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { throwIICBOE("NotExistsSubQuery"); return null; }
#end
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#if (!${referrer.isOneToOne()})
#set ($relatedCBClassName = "${referrer.referrerTableExtendedConditionBeanClassName}")
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_SpecifyDerivedReferrer_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_SpecifyDerivedReferrer_${referrer.referrerPropertyNameInitCap}")
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { throwIICBOE("(Specify)DerivedReferrer"); return null; }
#end
#end
#end
#if (${col.hasSingleKeyReferrer()})
#foreach ($referrer in $col.singleKeyReferrers)
#if (!${referrer.isOneToOne()})
#set ($relatedCBClassName = "${referrer.referrerTableExtendedConditionBeanClassName}")
#set ($relatedCQClassName = "${referrer.referrerTableExtendedConditionQueryClassName}")
#set ($subQueryPropertyNameInitCap = "${tmpJavaName}_QueryDerivedReferrer_${referrer.referrerPropertyNameInitCap}")
#set ($subQueryPropertyName = "${tmpUncapitalisedJavaName}_QueryDerivedReferrer_${referrer.referrerPropertyNameInitCap}")
    public String keep${subQueryPropertyNameInitCap}(${relatedCQClassName} sq)
    { throwIICBOE("(Query)DerivedReferrer"); return null; }
    public String keep${subQueryPropertyNameInitCap}Parameter(Object pv)
    { throwIICBOE("(Query)DerivedReferrer"); return null; }
#end
#end
#end
#end
#end
#if ($table.hasOnlyOnePrimaryKey())
    public String keepScalarSubQuery(${myConditionQueryClassName} subQuery)
    { throwIICBOE("ScalarSubQuery"); return null; }
    public String keepMyselfInScopeSubQuery(${myConditionQueryClassName} subQuery)
    { throwIICBOE("MyselfInScopeSubQuery"); return null;}
#end

    protected void throwIICBOE(String name) { // throwInlineIllegalConditionBeanOperationException()
        throw new IllegalConditionBeanOperationException("Sorry! " + name + " at in-line view is unavailable!");
    }

    // ===================================================================================
    //                                                                       Very Internal
    //                                                                       =============
    // Very Internal (for Suppressing Warn about 'Not Use Import')
    String xiCB() { return ${myConditionBeanClassName}.class.getName(); }
    String xiCQ() { return ${myConditionQueryClassName}.class.getName(); }
}
