Search in sources :

Example 1 with BeanMethodNotFoundException

use of org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException 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;
}
Also used : BeanMethodNotFoundException(org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException) OptionalThing(org.dbflute.optional.OptionalThing) BeanDesc(org.lastaflute.di.helper.beans.BeanDesc) Classification(org.dbflute.jdbc.Classification) Method(java.lang.reflect.Method)

Example 2 with BeanMethodNotFoundException

use of org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException in project lastaflute by lastaflute.

the class LaClassificationUtil method nativeCodeOf.

// -----------------------------------------------------
// Code-of
// -------
public static Object nativeCodeOf(Class<?> cdefType, Object code) {
    // old method
    assertArgumentNotNull("cdefType", cdefType);
    assertArgumentNotNull("code", code);
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(cdefType);
    final String methodName = "codeOf";
    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 ClassificationCodeOfMethodNotFoundException(msg, e);
    }
    return DfReflectionUtil.invokeStatic(method, new Object[] { code });
}
Also used : BeanMethodNotFoundException(org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException) BeanDesc(org.lastaflute.di.helper.beans.BeanDesc) Method(java.lang.reflect.Method)

Example 3 with BeanMethodNotFoundException

use of org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException in project lastaflute by lastaflute.

the class LaClassificationUtil method nativeMetaOf.

// -----------------------------------------------------
// Meta of
// -------
public static Object nativeMetaOf(Class<?> defmetaType, String classificationName) {
    // old method
    assertArgumentNotNull("defmetaType", defmetaType);
    assertArgumentNotNull("classificationName", classificationName);
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(defmetaType);
    final String methodName = "meta";
    final Method method;
    try {
        method = beanDesc.getMethod(methodName, new Class<?>[] { String.class });
    } catch (BeanMethodNotFoundException e) {
        String msg = "Failed to get the method " + methodName + "() of the def-meta type: " + defmetaType;
        throw new ClassificationMetaOfMethodNotFoundException(msg, e);
    }
    return DfReflectionUtil.invokeStatic(method, new Object[] { classificationName });
}
Also used : BeanMethodNotFoundException(org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException) BeanDesc(org.lastaflute.di.helper.beans.BeanDesc) Method(java.lang.reflect.Method)

Example 4 with BeanMethodNotFoundException

use of org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException in project lastaflute by lastaflute.

the class LaClassificationUtil method nativeFindMeta.

// -----------------------------------------------------
// meta.find(name)
// ---------------
protected static OptionalThing<ClassificationMeta> nativeFindMeta(Class<?> defmetaType, String classificationName) {
    // old method
    assertArgumentNotNull("defmetaType", defmetaType);
    assertArgumentNotNull("classificationName", classificationName);
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(defmetaType);
    final String methodName = "find";
    final Method method;
    try {
        method = beanDesc.getMethod(methodName, new Class<?>[] { String.class });
    } catch (BeanMethodNotFoundException e) {
        String msg = "Failed to get the method " + methodName + "() of the def-meta type: " + defmetaType;
        throw new ClassificationMetaFindMethodNotFoundException(msg, e);
    }
    @SuppressWarnings("unchecked") OptionalThing<ClassificationMeta> opt = (OptionalThing<ClassificationMeta>) DfReflectionUtil.invokeStatic(method, new Object[] { classificationName });
    return opt;
}
Also used : BeanMethodNotFoundException(org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException) ClassificationMeta(org.dbflute.jdbc.ClassificationMeta) OptionalThing(org.dbflute.optional.OptionalThing) BeanDesc(org.lastaflute.di.helper.beans.BeanDesc) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)4 BeanDesc (org.lastaflute.di.helper.beans.BeanDesc)4 BeanMethodNotFoundException (org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException)4 OptionalThing (org.dbflute.optional.OptionalThing)2 Classification (org.dbflute.jdbc.Classification)1 ClassificationMeta (org.dbflute.jdbc.ClassificationMeta)1