当前位置: 首页>>代码示例>>Java>>正文


Java BeanDescFactory类代码示例

本文整理汇总了Java中org.lastaflute.di.helper.beans.factory.BeanDescFactory的典型用法代码示例。如果您正苦于以下问题:Java BeanDescFactory类的具体用法?Java BeanDescFactory怎么用?Java BeanDescFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BeanDescFactory类属于org.lastaflute.di.helper.beans.factory包,在下文中一共展示了BeanDescFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareSimpleProperty

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
protected Object prepareSimpleProperty(Object bean, String name) {
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
    if (!beanDesc.hasPropertyDesc(name)) {
        return null;
    }
    final PropertyDesc pd = beanDesc.getPropertyDesc(name);
    if (!pd.isReadable()) {
        return null;
    }
    Object value = pd.getValue(bean);
    if (value == null) {
        final Class<?> propertyType = pd.getPropertyType();
        if (!LdiModifierUtil.isAbstract(propertyType)) {
            value = LdiClassUtil.newInstance(propertyType);
            if (pd.isWritable()) {
                pd.setValue(bean, value);
            }
        } else if (Map.class.isAssignableFrom(propertyType)) {
            value = new HashMap<String, Object>();
            if (pd.isWritable()) {
                pd.setValue(bean, value);
            }
        }
    }
    return value;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:27,代码来源:ActionFormMapper.java

示例2: setSimpleProperty

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
protected void setSimpleProperty(VirtualForm virtualForm, Object bean, String name, Object value, StringBuilder pathSb,
        FormMappingOption option, Object parentBean, String parentName) {
    if (bean instanceof Map) {
        @SuppressWarnings("unchecked")
        final Map<String, Object> map = (Map<String, Object>) bean;
        setMapProperty(map, name, value, option, parentBean, parentName);
        return;
    }
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
    if (!beanDesc.hasPropertyDesc(name)) {
        handleUndefinedParameter(bean, name, value, option, beanDesc);
        return;
    }
    final PropertyDesc pd = beanDesc.getPropertyDesc(name);
    if (!pd.isWritable()) {
        handleUndefinedParameter(bean, name, value, option, beanDesc);
        return;
    }
    try {
        mappingToProperty(virtualForm, bean, name, value, pathSb, option, pd);
    } catch (RuntimeException e) {
        handleMappingFailureException(beanDesc, name, value, pathSb, pd, e);
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:25,代码来源:ActionFormMapper.java

示例3: detectLonelyAnnotatedField

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
protected void detectLonelyAnnotatedField(Field field, Class<?> beanType, Map<String, Class<?>> genericMap, Deque<String> pathDeque,
        Set<Class<?>> checkedTypeSet) {
    final boolean hasNestedBeanAnnotation = hasNestedBeanAnnotation(field);
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(beanType);
    for (int i = 0; i < beanDesc.getFieldSize(); i++) {
        final Field nestedField = beanDesc.getField(i);
        if (!hasNestedBeanAnnotation) {
            for (Annotation anno : nestedField.getAnnotations()) {
                if (isValidatorAnnotation(anno.annotationType())) {
                    throwLonelyValidatorAnnotationException(field, nestedField); // only first level
                }
            }
        }
        doCheckLonelyValidatorAnnotation(nestedField, deriveFieldType(nestedField, genericMap)); // recursive call
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:17,代码来源:ExecuteMethodValidatorChecker.java

示例4: doCheckJsonBeanValidator

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
protected void doCheckJsonBeanValidator(Class<?> jsonBeanType, Map<String, Class<?>> genericMap) {
    final Deque<String> pathDeque = new LinkedList<String>(); // recycled
    final Set<Class<?>> mismatchedCheckedTypeSet = DfCollectionUtil.newHashSet(jsonBeanType);
    final Set<Class<?>> lonelyCheckedTypeSet = DfCollectionUtil.newHashSet(jsonBeanType);
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(jsonBeanType);
    final int pdSide = beanDesc.getPropertyDescSize();
    for (int i = 0; i < pdSide; i++) {
        final PropertyDesc pd = beanDesc.getPropertyDesc(i);
        final Field field = pd.getField();
        if (field != null) {
            pathDeque.clear(); // to recycle
            checkJsonBeanMismatchedValidatorAnnotation(jsonBeanType, pd, field, pathDeque, mismatchedCheckedTypeSet, genericMap);
            pathDeque.clear(); // to recycle
            checkJsonBeanLonelyValidatorAnnotation(jsonBeanType, pd, field, pathDeque, lonelyCheckedTypeSet, genericMap);
        }
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:ExecuteMethodChecker.java

示例5: nativeFindByCode

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
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;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:LaClassificationUtil.java

示例6: nativeFindMeta

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
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;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:LaClassificationUtil.java

示例7: resolveBeanExpression

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
protected static String resolveBeanExpression(Object obj, Map<Object, String> alreadyAppearedSet) {
    if (obj == null) {
        throw new IllegalArgumentException("The argument 'obj' should not be null.");
    }
    final Class<? extends Object> targetType = obj.getClass();
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(targetType);
    final int propertySize = beanDesc.getPropertyDescSize();
    final StringBuilder sb = new StringBuilder();
    sb.append("{");
    for (int i = 0; i < propertySize; i++) {
        final PropertyDesc pd = beanDesc.getPropertyDesc(i);
        final String propertyName = pd.getPropertyName();
        final Object propertyValue = pd.getValue(obj);
        final String exp = deriveExpression(propertyValue, alreadyAppearedSet, () -> {
            return resolveObjectString(propertyValue, alreadyAppearedSet);
        });
        sb.append(i > 0 ? ", " : "").append(propertyName).append("=").append(exp);
    }
    sb.append("}");
    return sb.toString();
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:22,代码来源:Lato.java

示例8: appendInterType

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
public void appendInterType(ComponentDef componentDef) {
    Class<?> componentClass = componentDef.getComponentClass();
    if (componentClass == null) {
        return;
    }
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(componentClass);
    if (!beanDesc.hasField(INTER_TYPE)) {
        return;
    }
    String interTypeStr = (String) beanDesc.getFieldValue(INTER_TYPE, null);
    String[] array = LdiStringUtil.split(interTypeStr, ", ");
    for (int i = 0; i < array.length; i += 2) {
        String interTypeName = array[i].trim();
        appendInterType(componentDef, interTypeName);
    }
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:17,代码来源:ConstantAnnotationHandler.java

示例9: evaluate

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
@Override
public Object evaluate(Map<String, ? extends Object> context, LaContainer container, Class<?> conversionType) {
    final MethodInterceptor interceptor = MethodInterceptor.class.cast(container.getComponent(getInterceptorName(annotation)));
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(interceptor.getClass());
    for (final Method method : annotation.annotationType().getMethods()) {
        if (method.isBridge() || method.isSynthetic()) {
            continue;
        }
        final String propertyName = method.getName();
        if ("pointcut".equals(propertyName) || !beanDesc.hasPropertyDesc(propertyName)) {
            continue;
        }
        final PropertyDesc propertyDesc = beanDesc.getPropertyDesc(propertyName);
        if (!propertyDesc.isWritable()) {
            continue;
        }
        propertyDesc.setValue(interceptor, LdiMethodUtil.invoke(method, annotation, null));
    }
    return interceptor;
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:21,代码来源:MetaAnnotationAspectDefBuilder.java

示例10: invoke

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
public Object invoke(MethodInvocation invocation) throws Throwable {
    if (targetName == null) {
        throw new EmptyRuntimeException("targetName");
    }
    final Method method = invocation.getMethod();
    if (!LdiMethodUtil.isAbstract(method)) {
        return invocation.proceed();
    }
    String methodName = method.getName();
    if (methodNameMap.containsKey(methodName)) {
        methodName = (String) methodNameMap.get(methodName);
    }
    final Object target = container.getComponent(targetName);
    if (beanDesc == null) {
        beanDesc = BeanDescFactory.getBeanDesc(target.getClass());
    }
    if (!beanDesc.hasMethod(methodName)) {
        throw new BeanMethodNotFoundException(getTargetClass(invocation), methodName, invocation.getArguments());
    }
    return beanDesc.invoke(target, methodName, invocation.getArguments());
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:22,代码来源:PrototypeDelegateInterceptor.java

示例11: isMapValueStringArray

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
protected boolean isMapValueStringArray(Object parentBean, String parentName) {
    if (parentBean == null) {
        return false;
    }
    final PropertyDesc pd = BeanDescFactory.getBeanDesc(parentBean.getClass()).getPropertyDesc(parentName);
    final Class<?> valueClassOfMap = pd.getValueClassOfMap();
    return valueClassOfMap != null && valueClassOfMap.isArray() && String[].class.isAssignableFrom(valueClassOfMap);
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:9,代码来源:ActionFormMapper.java

示例12: prepareJsonParameterDebugChallengeList

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
protected List<JsonDebugChallenge> prepareJsonParameterDebugChallengeList(Map<String, Object> retryMap, Class<?> beanType, String json,
        Integer elementIndex) {
    if (retryMap.isEmpty()) {
        return Collections.emptyList();
    }
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(beanType);
    final int fieldSize = beanDesc.getFieldSize();
    final List<JsonDebugChallenge> challengeList = new ArrayList<JsonDebugChallenge>(fieldSize);
    for (int i = 0; i < fieldSize; i++) {
        final Field field = beanDesc.getField(i);
        final JsonDebugChallenge challenge = createJsonDebugChallenge(retryMap, field.getName(), field.getType(), elementIndex);
        challengeList.add(challenge);
    }
    return Collections.unmodifiableList(challengeList);
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:16,代码来源:ActionFormMapper.java

示例13: setIndexedProperty

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
protected void setIndexedProperty(Object bean, String name, int[] indexes, Object value, FormMappingOption option) { // e.g. sea[0]
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
    if (!beanDesc.hasPropertyDesc(name)) {
        return;
    }
    final PropertyDesc pd = beanDesc.getPropertyDesc(name);
    if (!pd.isWritable()) {
        return;
    }
    if (value.getClass().isArray() && Array.getLength(value) > 0) {
        value = Array.get(value, 0);
    }
    final Class<?> propertyType = pd.getPropertyType();
    if (propertyType.isArray()) {
        Object array = pd.getValue(bean);
        final Class<?> elementType = getArrayElementType(propertyType, indexes.length);
        if (array == null) {
            int[] newIndexes = new int[indexes.length];
            newIndexes[0] = indexes[0] + 1;
            array = Array.newInstance(elementType, newIndexes);
        }
        array = expand(array, indexes, elementType);
        pd.setValue(bean, array);
        setArrayValue(array, indexes, value);
    } else { // e.g. List, ImmutableList, MutableList
        // process of your collections should be first because MutableList is java.util.List 
        final Optional<FormYourCollectionResource> yourCollection = findListableYourCollection(pd, option);
        if (yourCollection.isPresent()) { // e.g. ImmutableList, MutableList
            doSetIndexedPropertyListable(bean, name, indexes, value, beanDesc, pd, option, newList -> {
                @SuppressWarnings("unchecked")
                final List<Object> filtered = (List<Object>) yourCollection.get().getYourCollectionCreator().apply(newList);
                return filtered;
            });
        } else if (List.class.isAssignableFrom(propertyType)) {
            doSetIndexedPropertyListable(bean, name, indexes, value, beanDesc, pd, option, Function.identity());
        } else {
            throwIndexedPropertyNotListArrayException(beanDesc, pd);
        }
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:41,代码来源:ActionFormMapper.java

示例14: prepareIndexedProperty

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
protected Object prepareIndexedProperty(Object bean, String name, int[] indexes, FormMappingOption option) {
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
    if (!beanDesc.hasPropertyDesc(name)) {
        return null;
    }
    final PropertyDesc pd = beanDesc.getPropertyDesc(name);
    if (!pd.isReadable()) {
        return null;
    }
    final Class<?> propertyType = pd.getPropertyType();
    if (propertyType.isArray()) {
        Object array = pd.getValue(bean);
        final Class<?> elementType = getArrayElementType(propertyType, indexes.length);
        if (array == null) {
            int[] newIndexes = new int[indexes.length];
            newIndexes[0] = indexes[0] + 1;
            array = Array.newInstance(elementType, newIndexes);
        }
        array = expand(array, indexes, elementType);
        pd.setValue(bean, array);
        return getArrayValue(array, indexes, elementType);
    } else { // e.g. List, ImmutableList, MutableList
        // process of your collections should be first because MutableList is java.util.List 
        final Optional<FormYourCollectionResource> yourCollection = findListableYourCollection(pd, option);
        if (yourCollection.isPresent()) { // e.g. ImmutableList, MutableList
            return doPrepareIndexedPropertyListable(bean, name, indexes, beanDesc, pd, option, newList -> {
                @SuppressWarnings("unchecked")
                final List<Object> filtered = (List<Object>) yourCollection.get().getYourCollectionCreator().apply(newList);
                return filtered;
            });
        } else if (List.class.isAssignableFrom(propertyType)) { // e.g. List (can be ArrayList)
            return doPrepareIndexedPropertyListable(bean, name, indexes, beanDesc, pd, option, Function.identity());
        } else { // cannot treat it
            throwIndexedPropertyNotListArrayException(beanDesc, pd);
            return null; // unreachable
        }
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:39,代码来源:ActionFormMapper.java

示例15: setupProperties

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入依赖的package包/类
protected Map<String, ActionFormProperty> setupProperties(Class<?> formType) {
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(formType);
    final int propertyDescSize = beanDesc.getPropertyDescSize();
    final Map<String, ActionFormProperty> map = new HashMap<String, ActionFormProperty>(propertyDescSize);
    for (int i = 0; i < propertyDescSize; i++) {
        final PropertyDesc pd = beanDesc.getPropertyDesc(i);
        if (pd.isReadable()) {
            final ActionFormProperty property = newActionFormProperty(pd);
            addProperty(map, property);
        }
    }
    return map;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:14,代码来源:ActionFormMeta.java


注:本文中的org.lastaflute.di.helper.beans.factory.BeanDescFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。