OSDN Git Service

DBFlute-0.9.3に更新
[ea2ddl/ea2ddl.git] / ea2ddl-gen / dbflute / templates / om / csharp / allcommon / cbean / ckey / ConditionKey.vmnet
1 #set ($myClassName = "${glConditionKeyName}")\r
2 \r
3 using System;\r
4 \r
5 using ${glPackageBaseCommonCOption};\r
6 using ${glPackageBaseCommonCValue};\r
7 using ${glPackageBaseCommonJavaLike};\r
8 \r
9 namespace ${glPackageBaseCommonCKey} {\r
10 \r
11 public abstract class ${myClassName} {\r
12 \r
13     // ===================================================================================\r
14     //                                                                          Definition\r
15     //                                                                          ==========\r
16     /** Mark of replaced value. */\r
17     public static readonly String MARK_OF_REPLACED_VALUE = "ReplacedValue";\r
18 \r
19     /** The condition key of equal. */\r
20     public static readonly ${myClassName} CK_EQUAL = new ${myClassName}Equal();\r
21 \r
22     /** The condition key of notEqual. */\r
23     public static readonly ${myClassName} CK_NOT_EQUAL = new ${myClassName}NotEqual();\r
24 \r
25     /** The condition key of greaterThan. */\r
26     public static readonly ${myClassName} CK_GREATER_THAN = new ${myClassName}GreaterThan();\r
27 \r
28     /** The condition key of lessrThan. */\r
29     public static readonly ${myClassName} CK_LESS_THAN = new ${myClassName}LessThan();\r
30 \r
31     /** The condition key of greaterEqual. */\r
32     public static readonly ${myClassName} CK_GREATER_EQUAL = new ${myClassName}GreaterEqual();\r
33 \r
34     /** The condition key of lessEqual. */\r
35     public static readonly ${myClassName} CK_LESS_EQUAL = new ${myClassName}LessEqual();\r
36 \r
37     /** The condition key of prefixSearch. */\r
38     public static readonly ${myClassName} CK_PREFIX_SEARCH = new ${myClassName}PrefixSearch();\r
39 \r
40     /** The condition key of likeSearch. */\r
41     public static readonly ${myClassName} CK_LIKE_SEARCH = new ${myClassName}LikeSearch();\r
42 \r
43     /** The condition key of inScope. */\r
44     public static readonly ${myClassName} CK_IN_SCOPE = new ${myClassName}InScope();\r
45 \r
46     /** The condition key of notInScope. */\r
47     public static readonly ${myClassName} CK_NOT_IN_SCOPE = new ${myClassName}NotInScope();\r
48 \r
49     /** The condition key of isNull. */\r
50     public static readonly ${myClassName} CK_IS_NULL = new ${myClassName}IsNull();\r
51 \r
52     /** The condition key of isNotNull. */\r
53     public static readonly ${myClassName} CK_IS_NOT_NULL = new ${myClassName}IsNotNull();\r
54 \r
55     /** Dummy-object for IsNull and IsNotNull and so on... */\r
56     protected static readonly Object DUMMY_OBJECT = new Object();\r
57 \r
58     // ===================================================================================\r
59     //                                                                           Attribute\r
60     //                                                                           =========\r
61     /** Condition-key. */\r
62     protected String _conditionKey;\r
63 \r
64     /** Operand. */\r
65     protected String _operand;\r
66 \r
67     // ===================================================================================\r
68     //                                                                         Main Method\r
69     //                                                                         ===========\r
70     public String getConditionKey() {\r
71         // Because initial charactor of property name is capital in dotNet world.\r
72         return (_conditionKey != null ? _conditionKey.Substring(0, 1).ToUpper() + _conditionKey.Substring(1) : null);\r
73     }\r
74 \r
75     public String getOperand() {\r
76         return _operand;\r
77     }\r
78 \r
79     abstract public bool isValidRegistration(${glConditionValueName} conditionValue, Object value, String callerName);\r
80 \r
81     public ${myClassName} addWhereClause(List<String> conditionList, String columnName, ${glConditionValueName} value) {\r
82         if (value == null) {\r
83             String msg = "Argument[value] must not be null:";\r
84             throw new IllegalArgumentException(msg + " value=" + value + " this.ToString()=" + ToString());\r
85         }\r
86         doAddWhereClause(conditionList, columnName, value);\r
87         return this;\r
88     }\r
89 \r
90     public ${myClassName} addWhereClause(List<String> conditionList, String columnName, ${glConditionValueName} value, ${glConditionOptionInterfaceName} option) {\r
91         if (value == null) {\r
92             String msg = "Argument[value] must not be null:";\r
93             throw new IllegalArgumentException(msg + " value=" + value + " this.ToString()=" + ToString());\r
94         }\r
95         doAddWhereClause(conditionList, columnName, value, option);\r
96         return this;\r
97     }\r
98         \r
99     abstract protected void doAddWhereClause(List<String> conditionList, String columnName, ${glConditionValueName} value);\r
100     abstract protected void doAddWhereClause(List<String> conditionList, String columnName, ${glConditionValueName} value, ${glConditionOptionInterfaceName} option);\r
101 \r
102     public ${glConditionValueName} setupConditionValue(${glConditionValueName} conditionValue, Object value, String location) {\r
103         if (conditionValue == null) {\r
104             String msg = "Argument[conditionValue] must not be null:";\r
105             throw new IllegalArgumentException(msg + " value=" + value + " this.ToString()=" + ToString());\r
106         }\r
107         doSetupConditionValue(conditionValue, value, location);\r
108         return conditionValue;\r
109     }\r
110 \r
111     public ${glConditionValueName} setupConditionValue(${glConditionValueName} conditionValue, Object value, String location, ${glConditionOptionInterfaceName} option) {\r
112         if (conditionValue == null) {\r
113             String msg = "Argument[conditionValue] must not be null:";\r
114             throw new IllegalArgumentException(msg + " value=" + value + " this.ToString()=" + ToString());\r
115         }\r
116         doSetupConditionValue(conditionValue, value, location, option);\r
117         return conditionValue;\r
118     }\r
119         \r
120     abstract protected void doSetupConditionValue(${glConditionValueName} conditionValue, Object value, String location);\r
121     abstract protected void doSetupConditionValue(${glConditionValueName} conditionValue, Object value, String location, ${glConditionOptionInterfaceName} option);\r
122 \r
123     protected String buildBindClause(String columnName, String location) {\r
124         return columnName + " " + getOperand() + " " + "/*dto." + location + "*/null";\r
125     }\r
126 \r
127     protected String buildBindClauseWithRearOption(String columnName, String location, String rearOption) {\r
128         return columnName + " " + getOperand() + " " + "/*dto." + location + "*/null" + rearOption;\r
129     }\r
130 \r
131     protected String buildBindClause(String columnName, String location, String dummyValue) {\r
132         return columnName + " " + getOperand() + " " + "/*dto." + location + "*/" + dummyValue;\r
133     }\r
134 \r
135     protected String buildClauseWithoutValue(String columnName) {\r
136         return columnName + " " + getOperand();\r
137     }\r
138 \r
139     protected String getWildCard() {\r
140         return "${database.WildCard}";\r
141     }\r
142 \r
143     // ===================================================================================\r
144     //                                                                      Basic Override\r
145     //                                                                      ==============\r
146     public override int GetHashCode() {\r
147         return getConditionKey().GetHashCode();\r
148     }\r
149 \r
150     public override bool Equals(Object other) {\r
151         if (other is ${myClassName}) {\r
152             if (this.getConditionKey().Equals(((${myClassName})other).getConditionKey())) {\r
153                 return true;\r
154             }\r
155         }\r
156         return false;\r
157     }\r
158 \r
159     public override String ToString() {\r
160         return "${myClassName}: " + getConditionKey() + " " + getOperand() + " wild-card=[" + getWildCard() + "]";\r
161     }\r
162 }\r
163 }\r