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


Java Modifier.isAbstract方法代码示例

本文整理汇总了Java中java.lang.reflect.Modifier.isAbstract方法的典型用法代码示例。如果您正苦于以下问题:Java Modifier.isAbstract方法的具体用法?Java Modifier.isAbstract怎么用?Java Modifier.isAbstract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.Modifier的用法示例。


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

示例1: registStaticScript

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
 * 注册静态脚本
 * @param scriptClass
 */
protected final void registStaticScript(Class<? extends T> scriptClass)
{
	try {
		boolean isAbstractOrInterface = Modifier.isAbstract(scriptClass.getModifiers())
				|| Modifier.isInterface(scriptClass.getModifiers());// 是否是抽象类
		if(isAbstractOrInterface)
		{
			throw new UnsupportedOperationException(scriptClass +"can not newInstance");
		}
		T script = scriptClass.newInstance();
		int code=script.getMessageCode();
		Class<? extends T> old=staticCodeMap.get(code);
		staticCodeMap.put(code,scriptClass);
		if(old==null)
		{
			_log.info("regist Static codeScript,code="+code+"(0x"+Integer.toHexString(code)+"),class="+scriptClass);
		}else
		{
			_log.info("regist Static codeScript,code="+code+"(0x"+Integer.toHexString(code)+"),class="+scriptClass+",Override script="+old);
		}
	} catch (Exception e) {
		_log.error(e.getMessage(),e);
	}
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:29,代码来源:AbstractStaticScriptFactory.java

示例2: createCollection

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static Collection<Object> createCollection(Class<?> type, int len) {
   	if (type.isAssignableFrom(ArrayList.class)) {
   		return  new ArrayList<Object>(len);
   	}
   	if (type.isAssignableFrom(HashSet.class)) {
   		return new HashSet<Object>(len);
   	}
   	if (! type.isInterface() && ! Modifier.isAbstract(type.getModifiers())) {
   		try {
			return (Collection<Object>) type.newInstance();
		} catch (Exception e) {
			// ignore
		}
   	}
   	return new ArrayList<Object>();
   }
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:18,代码来源:PojoUtils.java

示例3: newConstructorAccessor

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public ConstructorAccessor newConstructorAccessor(Constructor<?> c) {
    Class<?> declaringClass = c.getDeclaringClass();
    if (Modifier.isAbstract(declaringClass.getModifiers())) {
        return new InstantiationExceptionConstructorAccessorImpl(null);
    }
    if (declaringClass == Class.class) {
        return new InstantiationExceptionConstructorAccessorImpl
            ("Can not instantiate java.lang.Class");
    }
    return newConstructorAccessor0(c);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:ReflectionFactory.java

示例4: isJunit3Test

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static boolean isJunit3Test(Class<?> klass) {
    // public class FooTest extends TestCase {...}
    //   or
    // public class FooSuite {
    //    public static Test suite() {...}
    // }
    return (TestCase.class.isAssignableFrom(klass) && !Modifier.isAbstract(klass.getModifiers()))
            || new ClassAnalyzer(klass).hasMethod(true, Test.class, "suite");
}
 
开发者ID:dryganets,项目名称:vogar,代码行数:10,代码来源:Junit3.java

示例5: initializeEventMetrics

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private static void initializeEventMetrics() {
    Set<Class<? extends Event>> types = new Reflections("net.dv8tion.jda.core.events")
        .getSubTypesOf(Event.class);

    for (Class<? extends Event> type : types) {
        if (type.isInterface() || Modifier.isAbstract(type.getModifiers())) {
            continue;
        }
        Metrics.jdaEvents.labels(type.getSimpleName()).inc(0D);
    }
}
 
开发者ID:avaire,项目名称:avaire,代码行数:12,代码来源:Metrics.java

示例6: testCreation

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
 * Basic method for testing that a MBean of a given class can be
 * instantiated by the MBean server.<p>
 * This method checks that:
 * <ul><li>The given class is a concrete class.</li>
 *     <li>The given class exposes at least one public constructor.</li>
 * </ul>
 * If these conditions are not met, throws a NotCompliantMBeanException.
 * @param c The class of the MBean we want to create.
 * @exception NotCompliantMBeanException if the MBean class makes it
 *            impossible to instantiate the MBean from within the
 *            MBeanServer.
 *
 **/
public static void testCreation(Class<?> c)
    throws NotCompliantMBeanException {
    // Check if the class is a concrete class
    final int mods = c.getModifiers();
    if (Modifier.isAbstract(mods) || Modifier.isInterface(mods)) {
        throw new NotCompliantMBeanException("MBean class must be concrete");
    }

    // Check if the MBean has a public constructor
    final Constructor<?>[] consList = c.getConstructors();
    if (consList.length == 0) {
        throw new NotCompliantMBeanException("MBean class must have public constructor");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:Introspector.java

示例7: findInstanceAbleScript

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
 * 查找可实例化的脚本
 * @param scriptClazzs
 * @return
 * @throws InstantiationException
 * @throws IllegalAccessException
 */
private Map<Integer, Class<? extends T>> findInstanceAbleScript(Set<Class<? extends T>> scriptClazzs)
		throws InstantiationException, IllegalAccessException {
	Map<Integer, Class<? extends T>> codeMap = new ConcurrentHashMap<Integer, Class<? extends T>>();
	for (Class<? extends T> scriptClazz : scriptClazzs) 
	{
		boolean isAbstractOrInterface = Modifier.isAbstract(scriptClazz.getModifiers())|| Modifier.isInterface(scriptClazz.getModifiers());// 是否是抽象类
		if (!isAbstractOrInterface) {// 可实例化脚本
			T script = null;
			try {
				script=scriptClazz.newInstance();
			} catch (Exception e) {
				_log.error("can't newInstance ScriptClass:" + scriptClazz);
				continue;
			}
			int code = script.getMessageCode();
			if (codeMap.containsKey(script.getMessageCode())) {// 重复脚本code定义
				_log.error("find Repeat ScriptClass,code="+code+",addingScript:" + script.getClass() + ",existScript:"
						+ codeMap.get(code));
			} else {
				codeMap.put(code, scriptClazz);
				_log.info("regist ScriptClass:code="+code+",class=" + scriptClazz);
			}
		}
	}
	return codeMap;
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:34,代码来源:AbstractScriptProvider.java

示例8: convertParametersToObject

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private <T> Object convertParametersToObject(Class<T> clazz, Class<?> contentClass, Map<String, Object> fields)
        throws APICallException {
    return (List.class.isAssignableFrom(clazz)) ? Serializer.convertParametersToListObject(fields, contentClass)
            : (Modifier.isAbstract(clazz.getModifiers()) && !clazz.isPrimitive())
                    ? Serializer.convertParametersToObjectFromAbstractClasses(fields, clazz)
                    : Serializer.convertParametersToObject(fields, clazz);
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:8,代码来源:APIMethodArgument.java

示例9: isAbstract

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/** Returns true if the method is abstract. */
public final boolean isAbstract() {
  return Modifier.isAbstract(getModifiers());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:5,代码来源:Element.java

示例10: createUnitializedBinding

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
 * Creates a binding for an injectable type with the given scope. Looks for a scope on the type if
 * none is specified.
 */
<T> BindingImpl<T> createUnitializedBinding(Key<T> key, Scoping scoping, Object source,
                                            Errors errors) throws ErrorsException {
    Class<?> rawType = key.getTypeLiteral().getRawType();

    // Don't try to inject arrays, or enums.
    if (rawType.isArray() || rawType.isEnum()) {
        throw errors.missingImplementation(key).toException();
    }

    // Handle TypeLiteral<T> by binding the inner type
    if (rawType == TypeLiteral.class) {
        @SuppressWarnings("unchecked") // we have to fudge the inner type as Object
                BindingImpl<T> binding = (BindingImpl<T>) createTypeLiteralBinding(
                (Key<TypeLiteral<Object>>) key, errors);
        return binding;
    }

    // Handle @ImplementedBy
    ImplementedBy implementedBy = rawType.getAnnotation(ImplementedBy.class);
    if (implementedBy != null) {
        Annotations.checkForMisplacedScopeAnnotations(rawType, source, errors);
        return createImplementedByBinding(key, scoping, implementedBy, errors);
    }

    // Handle @ProvidedBy.
    ProvidedBy providedBy = rawType.getAnnotation(ProvidedBy.class);
    if (providedBy != null) {
        Annotations.checkForMisplacedScopeAnnotations(rawType, source, errors);
        return createProvidedByBinding(key, scoping, providedBy, errors);
    }

    // We can't inject abstract classes.
    // TODO: Method interceptors could actually enable us to implement
    // abstract types. Should we remove this restriction?
    if (Modifier.isAbstract(rawType.getModifiers())) {
        throw errors.missingImplementation(key).toException();
    }

    // Error: Inner class.
    if (Classes.isInnerClass(rawType)) {
        throw errors.cannotInjectInnerClass(rawType).toException();
    }

    if (!scoping.isExplicitlyScoped()) {
        Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, rawType);
        if (scopeAnnotation != null) {
            scoping = Scopes.makeInjectable(Scoping.forAnnotation(scopeAnnotation),
                    this, errors.withSource(rawType));
        }
    }

    return ConstructorBindingImpl.create(this, key, source, scoping);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:58,代码来源:InjectorImpl.java

示例11: isAbstract

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static boolean isAbstract(final Class<?> clazz) {
	return Modifier.isAbstract(clazz.getModifiers());
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:4,代码来源:Reflections.java

示例12: canBeStaticallyBound

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private static boolean canBeStaticallyBound(Member method) {
    int modifiers = method.getModifiers();
    return (Modifier.isFinal(modifiers) || Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers) || Modifier.isFinal(method.getDeclaringClass().getModifiers())) &&
                    !Modifier.isAbstract(modifiers);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TestResolvedJavaMethod.java

示例13: isAbstract

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/** Utility method to query the modifier flags of this member. */
public boolean isAbstract() {
    return Modifier.isAbstract(flags);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:MemberName.java

示例14: throwsInstantiationException

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static boolean throwsInstantiationException(ResolvedJavaType type, MetaAccessProvider metaAccess) {
    return type.isPrimitive() || type.isArray() || type.isInterface() || Modifier.isAbstract(type.getModifiers()) || type.equals(metaAccess.lookupJavaType(Class.class));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:DynamicNewInstanceNode.java

示例15: isAbstractOrInterface

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
protected final boolean isAbstractOrInterface(Class<?> clazz)
{
	return Modifier.isAbstract(clazz.getModifiers())|| Modifier.isInterface(clazz.getModifiers());// 是否是抽象类
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:5,代码来源:MapClassProvider.java


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