${database.allClassCopyright}package ${glPackageBaseCommon}; import java.util.HashMap; import java.util.Map; import org.seasar.dbflute.jdbc.Classification; import org.seasar.dbflute.jdbc.ClassificationCodeType; import org.seasar.dbflute.jdbc.ClassificationMeta; /** * The definition of classification. * @author ${database.classAuthor} */ public interface ${glCDef} extends Classification { public enum DefMeta implements ClassificationMeta { #set ($count = 0) #foreach ($classificationName in $database.classificationNameList) #set ($existTop = false) #if ($database.classificationTopDefinitionMap.containsKey($classificationName)) #set ($classificationTopMap = $database.classificationTopDefinitionMap.get($classificationName)) #set ($existTop = true) #end #if ($count != 0) , #end #if ($existTop && $classificationTopMap.containsKey('topComment')) /** $classificationTopMap.get('topComment') */ #end ${classificationName} #set ($count = $count + 1) #end ; public Classification codeOf(Object code) { #foreach ($classificationName in $database.classificationNameList) if ("${classificationName}".equals(name())) { return ${glCDef}.${classificationName}.codeOf(code); } #end throw new IllegalStateException("Unknown definition: " + this); // basically unreachable } public ClassificationCodeType codeType() { #foreach ($classificationName in $database.classificationNameList) #set ($existTop = false) #if ($database.classificationTopDefinitionMap.containsKey($classificationName)) #set ($classificationTopMap = $database.classificationTopDefinitionMap.get($classificationName)) #set ($existTop = true) #end #if ($existTop && $classificationTopMap.containsKey('codeType')) if ("${classificationName}".equals(name())) { return ClassificationCodeType.${classificationTopMap.get('codeType')}; } #end #end return ClassificationCodeType.String; // as default } } #foreach ($classificationName in $database.classificationNameList) #set ($classificationMapList = $database.classificationDefinitionMap.get($classificationName)) #set ($existTop = false) #if ($database.classificationTopDefinitionMap.containsKey($classificationName)) #set ($classificationTopMap = $database.classificationTopDefinitionMap.get($classificationName)) #set ($existTop = true) #end #if ($existTop && $classificationTopMap.containsKey('topComment')) /** * $classificationTopMap.get('topComment') */ #end public enum ${classificationName} implements ${glCDef} { #set ($count = 0) #foreach ($classificationMap in $classificationMapList) #if ($count != 0) , #end /** $database.buildClassificationApplicationComment($classificationMap) */ ${classificationMap.get('name')}($database.buildClassificationCodeAliasVariables($classificationMap)) #set ($count = $count + 1) #end ; private static final Map _codeValueMap = new HashMap(); static { for (${classificationName} value : values()) { _codeValueMap.put(value.code().toLowerCase(), value); } } private String _code; private String _alias; private ${classificationName}(String code, String alias) { _code = code; _alias = alias; } public String code() { return _code; } public String alias() { return _alias; } public ClassificationMeta meta() { return ${glCDef}.DefMeta.${classificationName}; } public static ${classificationName} codeOf(Object code) { if (code == null) { return null; } if (code instanceof ${classificationName}) { return (${classificationName})code; } return _codeValueMap.get(code.toString().toLowerCase()); } #if ($database.isCDefToStringReturnsName()) @Override public String toString() { return name(); } #else @Override public String toString() { return code(); } #end } #end }