本文整理了Java中java.lang.Class.isMemberClass()
方法的一些代码示例,展示了Class.isMemberClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Class.isMemberClass()
方法的具体详情如下:
包路径:java.lang.Class
类名称:Class
方法名:isMemberClass
[英]Tests whether the class represented by this Class is a member class.
[中]
代码示例来源:origin: libgdx/libgdx
/** Returns true if the class or interface represented by the supplied Class is a member class. */
static public boolean isMemberClass (Class c) {
return c.isMemberClass();
}
代码示例来源:origin: libgdx/libgdx
/** Returns true if the class or interface represented by the supplied Class is a member class. */
static public boolean isMemberClass (Class c) {
return c.isMemberClass();
}
代码示例来源:origin: redisson/redisson
@Override
public boolean isMemberType() {
return type.isMemberClass();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine if the supplied class is an <em>inner class</em>,
* i.e. a non-static member of an enclosing class.
* @return {@code true} if the supplied class is an inner class
* @since 5.0.5
* @see Class#isMemberClass()
*/
public static boolean isInnerClass(Class<?> clazz) {
return (clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers()));
}
代码示例来源:origin: junit-team/junit4
private Class<?> getEnclosingClassForNonStaticMemberClass(Class<?> currentTestClass) {
if (currentTestClass.isMemberClass() && !Modifier.isStatic(currentTestClass.getModifiers())) {
return currentTestClass.getEnclosingClass();
} else {
return null;
}
}
代码示例来源:origin: junit-team/junit4
public boolean isANonStaticInnerClass() {
return clazz.isMemberClass() && !isStatic(clazz.getModifiers());
}
代码示例来源:origin: google/j2objc
public boolean isANonStaticInnerClass() {
return fClass.isMemberClass() && !isStatic(fClass.getModifiers());
}
}
代码示例来源:origin: org.springframework/spring-core
/**
* Determine if the supplied class is an <em>inner class</em>,
* i.e. a non-static member of an enclosing class.
* @return {@code true} if the supplied class is an inner class
* @since 5.0.5
* @see Class#isMemberClass()
*/
public static boolean isInnerClass(Class<?> clazz) {
return (clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers()));
}
代码示例来源:origin: gocd/gocd
private boolean isANonStaticInnerClass(Class<?> candidateClass) {
return candidateClass.isMemberClass() && !Modifier.isStatic(candidateClass.getModifiers());
}
代码示例来源:origin: redisson/redisson
protected void check(Object task) {
if (task == null) {
throw new NullPointerException("Task is not defined");
}
if (task.getClass().isAnonymousClass()) {
throw new IllegalArgumentException("Task can't be created using anonymous class");
}
if (task.getClass().isMemberClass()
&& !Modifier.isStatic(task.getClass().getModifiers())) {
throw new IllegalArgumentException("Task class is an inner class and it should be static");
}
}
代码示例来源:origin: redisson/redisson
private void check(Object task) {
if (task == null) {
throw new NullPointerException("Task is not defined");
}
if (task.getClass().isAnonymousClass()) {
throw new IllegalArgumentException("Task can't be created using anonymous class");
}
if (task.getClass().isMemberClass()
&& !Modifier.isStatic(task.getClass().getModifiers())) {
throw new IllegalArgumentException("Task class is an inner class and it should be static");
}
}
代码示例来源:origin: org.mockito/mockito-core
private void checkNotInner(Field field) {
Class<?> type = field.getType();
if(type.isMemberClass() && !isStatic(type.getModifiers())) {
throw new MockitoException("the type '" + type.getSimpleName() + "' is an inner non static class.");
}
}
代码示例来源:origin: redisson/redisson
protected void check(Object task) {
if (task == null) {
throw new NullPointerException("Task is not defined");
}
if (task.getClass().isAnonymousClass()) {
throw new IllegalArgumentException("Task can't be created using anonymous class");
}
if (task.getClass().isMemberClass()
&& !Modifier.isStatic(task.getClass().getModifiers())) {
throw new IllegalArgumentException("Task class is an inner class and it should be static");
}
}
代码示例来源:origin: redisson/redisson
private void check(Object task) {
if (task == null) {
throw new NullPointerException("Task is not defined");
}
if (task.getClass().isAnonymousClass()) {
throw new IllegalArgumentException("Task can't be created using anonymous class");
}
if (task.getClass().isMemberClass()
&& !Modifier.isStatic(task.getClass().getModifiers())) {
throw new IllegalArgumentException("Task class is an inner class and it should be static");
}
}
代码示例来源:origin: alibaba/fastjson
static Constructor<?> getDefaultConstructor(Class<?> clazz, final Constructor<?>[] constructors) {
if (Modifier.isAbstract(clazz.getModifiers())) {
return null;
}
Constructor<?> defaultConstructor = null;
for (Constructor<?> constructor : constructors) {
if (constructor.getParameterTypes().length == 0) {
defaultConstructor = constructor;
break;
}
}
if (defaultConstructor == null) {
if (clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers())) {
Class<?>[] types;
for (Constructor<?> constructor : constructors) {
if ((types = constructor.getParameterTypes()).length == 1
&& types[0].equals(clazz.getDeclaringClass())) {
defaultConstructor = constructor;
break;
}
}
}
}
return defaultConstructor;
}
代码示例来源:origin: google/j2objc
private void checkNotInner(Field field) {
if(field.getType().isMemberClass() && !Modifier.isStatic(field.getType().getModifiers())) {
throw new MockitoException("the type '" + field.getType().getSimpleName() + "' is an inner class.");
}
}
代码示例来源:origin: nutzam/nutz
public boolean checkClass(Class<?> klass) {
return !(klass.isInterface()
|| klass.isArray()
|| klass.isEnum()
|| klass.isPrimitive()
|| klass.isMemberClass()
|| klass.isAnnotation()
|| klass.isAnonymousClass());
}
代码示例来源:origin: google/guava
cls.isMemberClass() && !Modifier.isStatic(cls.getModifiers())
? toGenericType(cls.getEnclosingClass()).runtimeType
: null;
代码示例来源:origin: querydsl/querydsl
@Override
public boolean apply(Class<?> input) {
return !input.isAnonymousClass()
&& !input.isMemberClass();
}
};
代码示例来源:origin: spring-projects/spring-framework
@SuppressWarnings("rawtypes")
private static void buildTypeVariableMap(ResolvableType type, Map<TypeVariable, Type> typeVariableMap) {
if (type != ResolvableType.NONE) {
Class<?> resolved = type.resolve();
if (resolved != null && type.getType() instanceof ParameterizedType) {
TypeVariable<?>[] variables = resolved.getTypeParameters();
for (int i = 0; i < variables.length; i++) {
ResolvableType generic = type.getGeneric(i);
while (generic.getType() instanceof TypeVariable<?>) {
generic = generic.resolveType();
}
if (generic != ResolvableType.NONE) {
typeVariableMap.put(variables[i], generic.getType());
}
}
}
buildTypeVariableMap(type.getSuperType(), typeVariableMap);
for (ResolvableType interfaceType : type.getInterfaces()) {
buildTypeVariableMap(interfaceType, typeVariableMap);
}
if (resolved != null && resolved.isMemberClass()) {
buildTypeVariableMap(ResolvableType.forClass(resolved.getEnclosingClass()), typeVariableMap);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!