當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。