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