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


Java ClassUtil类代码示例

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


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

示例1: resolveRender

import org.febit.util.ClassUtil; //导入依赖的package包/类
protected Render resolveRender(final ActionRequest actionRequest, final Object result) {
    Render render = null;
    for (Class<?> type : ClassUtil.impls(result.getClass())) {
        render = renderCache.get(type);
        if (render != null) {
            break;
        }
        RenderWith anno = type.getAnnotation(RenderWith.class);
        if (anno != null) {
            Class renderClass = anno.value();
            render = renderCache.get(renderClass);
            if (render != null) {
                break;
            }
            render = (Render) petite.get(renderClass);
            if (render != null) {
                render = renderCache.putIfAbsent(renderClass, render);
                break;
            }
        }
    }
    if (render == null) {
        render = defaultRender;
    }
    return renderCache.putIfAbsent(result.getClass(), render);
}
 
开发者ID:febit,项目名称:febit,代码行数:27,代码来源:RenderManager.java

示例2: resolveArgument

import org.febit.util.ClassUtil; //导入依赖的package包/类
@Override
public Argument resolveArgument(final Class<?> type, final String name, final int index) {
    Argument argument = argumentCache.get(type);
    if (argument != null) {
        return argument;
    }
    for (Class cls : ClassUtil.impls(type)) {
        argument = argumentCache.get(cls);
        if (argument != null) {
            break;
        }
    }
    if (argument == null) {
        argument = defaultArgument;
    }
    return argumentCache.putIfAbsent(type, argument);
}
 
开发者ID:febit,项目名称:febit,代码行数:18,代码来源:ArgumentManager.java

示例3: collectInfosIfAbsent

import org.febit.util.ClassUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static ArangoLinkInfo[] collectInfosIfAbsent(Class type) {
    ArangoLinkInfo[] infos = LINKS_CACHING.get(type);
    if (infos != null) {
        return infos;
    }

    final List<ArangoLinkInfo> list = new ArrayList<>();
    for (Field field : ClassUtil.getMemberFields(type)) {
        if (field.getType() != String.class) {
            continue;
        }
        ArangoLink linkAnno = field.getAnnotation(ArangoLink.class);
        if (linkAnno == null) {
            continue;
        }
        ClassUtil.setAccessible(field);
        Class<Entity> linkType = linkAnno.value();
        Class<?> serviceClass = linkAnno.service() != Object.class ? linkAnno.service()
                : linkType.getAnnotation(ArangoLink.class).value();

        list.add(new ArangoLinkInfo(((ArangoService) Services.get(serviceClass)).getDao(), field, linkType));
    }
    infos = list.isEmpty() ? EMPTY_LINKS : list.toArray(new ArangoLinkInfo[list.size()]);
    return LINKS_CACHING.putIfAbsent(type, infos);
}
 
开发者ID:febit,项目名称:febit,代码行数:27,代码来源:ArangoUtil.java

示例4: process

import org.febit.util.ClassUtil; //导入依赖的package包/类
private FieldInfos process() {
    FieldInfos fieldInfos = new FieldInfos();

    ClassUtil.getFields(beanType, this.fieldFilter)
            .forEach(fieldInfos::registField);

    // getters and setters
    for (Method method : beanType.getMethods()) {
        if (!methodFilter.test(method)) {
            continue;
        }
        fieldInfos.registMethod(method);
    }

    return fieldInfos;
}
 
开发者ID:febit,项目名称:febit-common,代码行数:17,代码来源:FieldInfoResolver.java

示例5: create

import org.febit.util.ClassUtil; //导入依赖的package包/类
public static HandlerConfig create(Object action, Method method, String macroString) {
    if (ClassUtil.isStatic(method)) {
        action = null;
    } else if (action == null) {
        throw new IllegalArgumentException("action is required to invoke member method: " + method);
    }
    ClassUtil.setAccessible(method);
    BasePathMacros macros = new RegExpPathMacros();
    boolean success = macros.init(macroString, MACRO_SEPARATORS);
    if (!success) {
        macros = null;
    }
    String[] names = macros == null
            ? new String[0]
            : macros.getNames();
    Class<?>[] paramTypes = method.getParameterTypes();
    String[] paramNames = resolveParameterNames(method);
    // assert paramNames.length == paramTypes.length
    int[] paramIndexer = new int[paramTypes.length];

    for (int i = 0; i < paramTypes.length; i++) {
        Class<?> paramType = paramTypes[i];
        if (OutgoingMessage.class.isAssignableFrom(paramType)) {
            paramIndexer[i] = -2;
        } else {
            String paramName = paramNames[i];
            int index = ArraysUtil.indexOf(names, paramName);
            paramIndexer[i] = index >= 0 ? index : -1;
        }
    }
    return new HandlerConfig(action, method, macroString, macros, paramTypes, paramIndexer);
}
 
开发者ID:febit,项目名称:febit,代码行数:33,代码来源:OutgoingManager.java

示例6: scanActions

import org.febit.util.ClassUtil; //导入依赖的package包/类
public void scanActions() {
    final List<Class> actionClasses = new ArrayList<>();
    final ClassScanner scanner = new ClassScanner() {

        @Override
        protected void onEntry(ClassFinder.EntryData ed) throws Exception {
            String className = ed.getName();
            if (!className.endsWith("Action")) {
                return;
            }
            Class actionClass = ClassUtil.getClass(className);
            if (ClassUtil.isAbstract(actionClass)
                    || _discardCaching.contains(actionClass)
                    || !AnnotationUtil.isAction(actionClass)) {
                return;
            }
            LOG.debug("Find action: {}", actionClass);
            actionClasses.add(actionClass);
        }
    };
    String[] includes = new String[_basePkgs.size()];
    for (int i = 0; i < _basePkgs.size(); i++) {
        includes[i] = _basePkgs.get(i)._1 + '*';
    }
    scanner.setExcludeAllEntries(true);
    scanner.setIncludeResources(false);
    scanner.setIncludedEntries(includes);
    scanner.scanDefaultClasspath();

    // register actions
    actionClasses.forEach(this::register);
}
 
开发者ID:febit,项目名称:febit,代码行数:33,代码来源:ActionManager.java

示例7: newInstance

import org.febit.util.ClassUtil; //导入依赖的package包/类
@Override
public Object newInstance(Class<?> type, Petite petite) {
    if (!isSupportType(type)) {
        return null;
    }
    if (type.isInterface()) {
        return null;
    }
    return ClassUtil.newInstance(type);
}
 
开发者ID:febit,项目名称:febit,代码行数:11,代码来源:ComponentPetiteProvider.java

示例8: resolveIdCenerator

import org.febit.util.ClassUtil; //导入依赖的package包/类
protected <E extends Entity> IdGenerator resolveIdCenerator(Class<E> entityType) {
    ArangoIdGenerator generatorAnno = entityType.getAnnotation(ArangoIdGenerator.class);
    if (generatorAnno == null) {
        return null;
    }
    Class<? extends IdGenerator> generatorType = generatorAnno.value();
    if (generatorType.equals(DefaultIdGenerator.class)) {
        return DefaultIdGenerator.getInstance();
    }
    if (generatorType.equals(IncreateIdGenerator.class)) {
        return IncreateIdGenerator.getInstance();
    }
    return ClassUtil.newInstance(generatorAnno.value());
}
 
开发者ID:febit,项目名称:febit,代码行数:15,代码来源:ArangoInitService.java

示例9: resolveFieldInfo

import org.febit.util.ClassUtil; //导入依赖的package包/类
public static Stream<FieldInfo> resolveFieldInfo(Class<?> type) {
    return FieldInfoResolver.of(type)
            .withNameFormatter(ArangoUtil::fixFieldName)
            .filterMethod(m -> false)
            .filterField(f -> !ClassUtil.isTransient(f) && ClassUtil.isSettable(f) && f.getAnnotation(ArangoIgnore.class) == null)
            .stream();
}
 
开发者ID:febit,项目名称:febit,代码行数:8,代码来源:ArangoUtil.java

示例10: resolveCheckConfigs

import org.febit.util.ClassUtil; //导入依赖的package包/类
protected CheckConfig[] resolveCheckConfigs(Class<?> type) {
    List<CheckConfig> checkConfigs = new ArrayList<>();
    FieldInfoResolver.of(type)
            .overrideFieldFilter(f -> ClassUtil.notStatic(f) && f.getAnnotations().length != 0)
            .stream()
            .filter(f -> f.getField() != null && f.isGettable())
            .forEach(f -> collectCheckConfig(f, checkConfigs::add));

    if (checkConfigs.isEmpty()) {
        return EMPTY_CHECK_CONFIGS;
    }
    return checkConfigs.toArray(new CheckConfig[checkConfigs.size()]);
}
 
开发者ID:febit,项目名称:febit-common,代码行数:14,代码来源:VtorChecker.java

示例11: createCheck

import org.febit.util.ClassUtil; //导入依赖的package包/类
protected Check createCheck(Class<? extends Annotation> annoType) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    Class checkType;
    String checkTypeName = annoType.getName() + "Check";
    try {
        checkType = ClassUtil.getClass(checkTypeName);
    } catch (ClassNotFoundException e) {
        // try to use annoType's classloader
        checkType = annoType.getClassLoader().loadClass(checkTypeName);
    }
    Check check = (Check) checkType.newInstance();
    Services.inject(check);
    return check;
}
 
开发者ID:febit,项目名称:febit-common,代码行数:14,代码来源:BaseVtorChecker.java

示例12: scanFormField

import org.febit.util.ClassUtil; //导入依赖的package包/类
private static void scanFormField(final Class<?> formClass, Consumer<FormField> consumer) {
    FieldInfoResolver.of(formClass)
            .overrideFieldFilter(f -> ClassUtil.notStatic(f) && f.getAnnotations().length != 0)
            .stream()
            .filter(f -> f.getField() != null && f.isGettable())
            .map(BaseFormUtil::toFormField)
            .filter(f -> f != null)
            .forEach(consumer);
}
 
开发者ID:febit,项目名称:febit-common,代码行数:10,代码来源:BaseFormUtil.java

示例13: toClass

import org.febit.util.ClassUtil; //导入依赖的package包/类
public static Class toClass(String string) {
    if (string == null) {
        return null;
    }
    try {
        return ClassUtil.getClass(string);
    } catch (ClassNotFoundException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:febit,项目名称:febit-common,代码行数:11,代码来源:Convert.java

示例14: newInstance

import org.febit.util.ClassUtil; //导入依赖的package包/类
@Override
public Object newInstance(Class<?> type, Petite petite) {
    if (!isSupportType(type)) {
        return null;
    }
    if (ClassUtil.isAbstract(type)) {
        return null;
    }
    return ClassUtil.newInstance(type);
}
 
开发者ID:febit,项目名称:febit-common,代码行数:11,代码来源:ServicePetiteProvider.java

示例15: openReader

import org.febit.util.ClassUtil; //导入依赖的package包/类
@Override
public Reader openReader(String path, String encoding) throws IOException {
    path = formatPath(path);
    if (path == null) {
        return null;
    }
    final InputStream in = ClassUtil.getDefaultClassLoader()
            .getResourceAsStream(path);
    if (in != null) {
        return new InputStreamReader(in, Defaults.or(encoding, StringPool.UTF_8));
    } else {
        throw new IOException("Resource Not Found: ".concat(path));
    }
}
 
开发者ID:febit,项目名称:febit-common,代码行数:15,代码来源:ClasspathResourceLoader.java


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