use of org.dbflute.jdbc.Classification in project dbflute-core by dbflute.
the class AbstractConditionQuery method cTNumL.
protected <PROPERTY extends Number> List<PROPERTY> cTNumL(Collection<? extends Classification> col, Class<PROPERTY> type) {
// convert to number list
if (col == null) {
return null;
}
final List<PROPERTY> list = new ArrayList<PROPERTY>();
for (Classification cls : col) {
if (cls != null) {
@SuppressWarnings("unchecked") final PROPERTY value = (PROPERTY) DfTypeUtil.toNumber(cls.code(), type);
list.add(value);
}
}
return list;
}
use of org.dbflute.jdbc.Classification in project dbflute-core by dbflute.
the class IfCommentEvaluatorTest method test_evaluate_cdef.
public void test_evaluate_cdef() {
// ## Arrange & Act && Assert ##
Classification cdef = new MyCDef();
// ## Act && Assert ##
assertTrue(createEvaluator(cdef, "pmb.code() == 'Pixy'").evaluate());
}
use of org.dbflute.jdbc.Classification in project dbflute-core by dbflute.
the class AbstractDBMeta method ccls.
// -----------------------------------------------------
// Write Converter
// ---------------
// these are static to avoid the FindBugs headache
// (implementations of PropertyGateway can be static class)
protected static void ccls(Entity entity, ColumnInfo columnInfo, Object code) {
// old style, for compatibility, check only on entity after Java8
if (code == null) {
// no check null value which means no existence on DB
return;
}
final ClassificationMeta meta = columnInfo.getClassificationMeta();
if (meta == null) {
// no way (just in case)
return;
}
final ClassificationUndefinedHandlingType undefinedHandlingType = meta.undefinedHandlingType();
if (!undefinedHandlingType.isChecked()) {
// basically no way (not called if no check)
return;
}
final Classification classification = gcls(entity, columnInfo, code);
if (classification == null) {
final String tableDbName = columnInfo.getDBMeta().getTableDbName();
final String columnDbName = columnInfo.getColumnDbName();
final boolean allowedByOption = entity.myundefinedClassificationAccessAllowed();
FunCustodial.handleUndefinedClassificationCode(tableDbName, columnDbName, meta, code, allowedByOption);
}
}
use of org.dbflute.jdbc.Classification in project dbflute-core by dbflute.
the class ManualOrderOption method resolveBoundValue.
// -----------------------------------------------------
// Resolve Bound
// -------------
protected Object resolveBoundValue(HpManualOrderThemeListHandler handler, Object plainValue, boolean suppressBinding) {
if (plainValue == null) {
return null;
}
if (plainValue instanceof SpecifiedColumn) {
return resolveDreamCruiseExp(plainValue);
}
ClassificationCodeType codeType = null;
if (plainValue instanceof Classification) {
final Classification cls = (Classification) plainValue;
plainValue = handleClassificationOrderValue(cls);
codeType = cls.meta().codeType();
}
final Object boundExp;
if (suppressBinding) {
if (plainValue instanceof String) {
if (canBeLiteralClassificationCodeType(codeType)) {
boundExp = plainValue;
} else {
String notice = "The binding of string value is unsupported on the DBMS.";
throwUnsupportedTypeSpecifiedException(notice, plainValue);
// unreachable
boundExp = null;
}
} else if (plainValue instanceof Number) {
boundExp = buildLiteralNumberExpression(plainValue);
} else if (isAnyLocalDate(plainValue) || plainValue instanceof Date) {
// #date_parade
boundExp = buildLiteralDateExpression(plainValue);
} else {
String notice = "The binding of the type is unsupported on the DBMS.";
throwUnsupportedTypeSpecifiedException(notice, plainValue);
// unreachable
boundExp = null;
}
} else {
boundExp = handler.register(THEME_KEY, plainValue);
}
return boundExp;
}
use of org.dbflute.jdbc.Classification in project lastaflute by lastaflute.
the class LaClassificationUtil method nativeFindByCode.
// ===================================================================================
// Native Method
// =============
// -----------------------------------------------------
// cls.of(code)
// ------------
protected static OptionalThing<Classification> nativeFindByCode(Class<?> cdefType, Object code) {
assertArgumentNotNull("cdefType", cdefType);
assertArgumentNotNull("code", code);
final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(cdefType);
final String methodName = "of";
final Method method;
try {
method = beanDesc.getMethod(methodName, new Class<?>[] { Object.class });
} catch (BeanMethodNotFoundException e) {
String msg = "Failed to get the method " + methodName + "() of the classification type: " + cdefType;
throw new ClassificationFindByCodeMethodNotFoundException(msg, e);
}
@SuppressWarnings("unchecked") final OptionalThing<Classification> opt = (OptionalThing<Classification>) DfReflectionUtil.invokeStatic(method, new Object[] { code });
return opt;
}
Aggregations