Example usage for java.lang Class getModifiers

List of usage examples for java.lang Class getModifiers

Introduction

In this page you can find the example usage for java.lang Class getModifiers.

Prototype

@HotSpotIntrinsicCandidate
public native int getModifiers();

Source Link

Document

Returns the Java language modifiers for this class or interface, encoded in an integer.

Usage

From source file:ModifierUtil.java

public static boolean isAbstract(Class<?> clazz) {
    return Modifier.isAbstract(clazz.getModifiers());
}

From source file:com.comcast.cereal.convert.MapCerealizer.java

private static boolean isInstantiable(Class<?> clazz) {
    boolean abs = Modifier.isAbstract(clazz.getModifiers());
    boolean hasConstuctor = ConstructorUtils.getAccessibleConstructor(clazz, new Class[0]) != null;
    return !clazz.isInterface() && !abs && hasConstuctor;
}

From source file:ModifierUtil.java

public static boolean isInterface(Class<?> clazz) {
    return Modifier.isInterface(clazz.getModifiers());
}

From source file:ModifierUtil.java

public static boolean isProtected(Class<?> clazz) {
    return Modifier.isProtected(clazz.getModifiers());
}

From source file:com.edmunds.autotest.ClassUtil.java

public static boolean isStandardClass(Class cls) {
    return !(((cls.getModifiers() & Modifier.ABSTRACT) > 0) || cls.isInterface() || cls.isMemberClass()
            || cls.isLocalClass() || cls.isSynthetic());
}

From source file:org.datalorax.populace.core.populate.instance.DefaultConstructorInstanceFactory.java

private static boolean isInnerClass(final Class<?> rawType) {
    return rawType.getEnclosingClass() != null && !Modifier.isStatic(rawType.getModifiers());
}

From source file:me.hurel.hqlbuilder.internal.ProxyUtil.java

public static boolean isFinal(Class<?> objectClass) {
    return (Modifier.FINAL & objectClass.getModifiers()) == Modifier.FINAL;
}

From source file:org.datalorax.populace.core.populate.instance.DefaultTypeInstanceFactory.java

private static boolean isConcrete(final Class<?> rawType) {
    return !rawType.isInterface() && !Modifier.isAbstract(rawType.getModifiers());
}

From source file:com.swingtech.commons.testing.JavaBeanTester.java

private static Object buildMockValue(Class<?> clazz) {
    if (!Modifier.isFinal(clazz.getModifiers())) {
        // Insert a call to your favourite mocking framework here
        return null;
    } else {//from  w w  w.  j a v  a 2  s . co  m
        return null;
    }
}

From source file:org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor.java

/**
 * Extracts the innermost delegate from the given Commons DBCP object.
 * Falls back to the given object if no underlying object found.
 * @param obj the Commons DBCP Connection/Statement/ResultSet
 * @return the underlying native Connection/Statement/ResultSet
 *///from www  . j a va  2  s  .  c  om
private static Object getInnermostDelegate(Object obj) throws SQLException {
    if (obj == null) {
        return null;
    }
    try {
        Class<?> classToAnalyze = obj.getClass();
        while (!Modifier.isPublic(classToAnalyze.getModifiers())) {
            classToAnalyze = classToAnalyze.getSuperclass();
            if (classToAnalyze == null) {
                // No public provider class found -> fall back to given object.
                return obj;
            }
        }
        Method getInnermostDelegate = classToAnalyze.getMethod(GET_INNERMOST_DELEGATE_METHOD_NAME,
                (Class[]) null);
        Object delegate = ReflectionUtils.invokeJdbcMethod(getInnermostDelegate, obj);
        return (delegate != null ? delegate : obj);
    } catch (NoSuchMethodException ex) {
        return obj;
    } catch (SecurityException ex) {
        throw new IllegalStateException("Commons DBCP getInnermostDelegate method is not accessible: " + ex);
    }
}